Jump to content

Variable length


datatek
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
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.

Link to comment
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

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...