Sign in to follow this  
Followers 0
datatek

Variable length

6 posts in this topic

Hello,

I would like my script to react to the fact that a string is empty, or at least < a certain number of characters.

If this is the case, the script should perform something (IF --> Else).

How would I implement this?

Thankyou for your much needed help.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If StringLen(GuiCtrlRead($input)) > 5 Then
            ;do something here
elseif StringLen(GuiCtrlRead($input)) = 0 Then
            ;do something here
endif

Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Share this post


Link to post
Share on other sites

If StringLen(GuiCtrlRead($input)) > 5 Then
            ;do something here
elseif StringLen(GuiCtrlRead($input)) = 0 Then
            ;do something here
endif

Thank you for your quick reply.

ATM my code is

If StringLen(GuiCtrlRead($variable) < 1 Then

send("{ESC}")

elseif StringLen(GuiCtrlRead($variable)) > 0 Then

[Rest of script]

I get the error message

If StringLen(GuiCtrlRead($variable) < 1 Then

If StringLen(GuiCtrlRead($variable) < 1 ^ ERROR

and the program exits.

Share this post


Link to post
Share on other sites

Thank you for your quick reply.

ATM my code is

If StringLen(GuiCtrlRead($variable) < 1 Then

send("{ESC}")

elseif StringLen(GuiCtrlRead($variable)) > 0 Then

[Rest of script]

I get the error message

If StringLen(GuiCtrlRead($variable) < 1 Then

If StringLen(GuiCtrlRead($variable) < 1 ^ ERROR

and the program exits.

are you closing the ()

If StringLen(GuiCtrlRead($variable)) < 1 Then


[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Share this post


Link to post
Share on other sites

and if the $variable isn't a GUI edit box or whatever. then it should just be:

If StringLen($variable) < 1 Then
send("{ESC}")
elseif StringLen($variable) > 0 Then

Share this post


Link to post
Share on other sites

Probably faster to go:

$len = StringLen ("String")

Switch $len
    Case 0
    ;Empty
    Case 1 To 5
    ;Len 1 to 5
EndSwitch

or

$len = StringLen ("String")

Select
    Case $len > 0 
    ;... Blah blah blah
EndSelect

Cheers

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0