Commands & Syntax > Commands > Macro Flow Control >

www.perfectkeyboard.com

 

IF STRING - < if_str >() ... [Pro]

 

IF STRING
<if_str>("expression")
Available in: Professional edition

The command evaluates a numeric expression and if it is evaluated as "true" then following macro steps (steps between "if" and "else/endif") are executed. All operands in the expression are considered to be strings (unlike "if_num" that consideres all operands to be numbers).

 

#

Parameter name

Parameter description

1

expression

Expression can contain brackets () and these operators are available:
== (is equal)
!= (is not equal)
<=
<
>=
>
~= (contains substring)
_AND_ (the condition is true AND also following condition is true)
_OR_ (the condition is tru OR the following condition is true)

Expression examples:
%Var1%==%Var2%
%str1%<%str2%
%vText%~=substring
(%str1%<%str2%) _AND_ (%vText%~=substring)

 

Example (Macro Steps):

 

1

<#> <#> This example shows how to use "if_str" command.

2

Macro execution: ONLY COMMANDS

3

Variable SET "v=", Message text="Type 'Hello' here"

4

IF STRING %v%==Hello

5

Message SHOW "Information" : "Yes! You really typed 'Hello'." (other parameters: x = -100, y = -100, Window title = Message, Buttons = OK, Timeout (seconds) = , Always on top = ).

6

ELSE activate

7

Message SHOW "Error" : "No, you have typed something else...." (other parameters: x = -100, y = -100, Window title = Message, Buttons = OK, Timeout (seconds) = , Always on top = ).

8

ENDIF

Example (Plain Text):

 

<#> This example shows how to use "if_str" command.

<cmds>

<varset>("v=","Type 'Hello' here")

<if_str>("%v%==Hello")

   <msg>(-100,-100,"Yes! You really typed 'Hello'.","Message",1,,0)

<else>

   <msg>(-100,-100,"No, you have typed something else....","Message",1,,2)

<endif>