Commands & Syntax > Commands > Macro Flow Control >

www.perfectkeyboard.com

 

IF - < if >() ... [Pro]

 

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

The command evaluates the expression and if it is evaluated as "true" then following macro steps (steps between "if" and "else/endif") are executed. The expression can contain EXPR(...) syntax.

 

#

Parameter name

Parameter description

1

expression

Expression can contain brackets () and these operators are available:
== (is equal)
!= (is not equal)
<= (is smalller or equal)
< (is smaller)
>= (is bigger or equal)
> (is bigger)
~= (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
10020) _AND_ (%vText%~=substring)

 

Example (Macro Steps):

 

1

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

2

Macro execution: ONLY COMMANDS

3

Variable SET "vNum=", Message text="Type a number:"

4

IF 100<(30+%vNum%)

5

Message SHOW "Information" : "Yes, this is true: 100<30+%vNum%" (other parameters: x = -100, y = -100, Window title = Message, Buttons = OK, Timeout (seconds) = , Always on top = ).

6

ELSE activate

7

Message SHOW "Error" : "No, it is not true: 100<30+%vNum%" (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" command.

<#>

<cmds>

<varset>("vNum=","Type a number:")

<if>("100<(30+%vNum%)")

<msg>(-100,-100,"Yes, this is true: 100<30+%vNum%","Message",1,,0)

<else>

<msg>(-100,-100,"No, it is not true: 100<30+%vNum%","Message",1,,2)

<endif>