Commands & Syntax > Commands > Macro Flow Control >

www.perfectkeyboard.com

 

Repeat steps UNTIL - < for >() ... [Pro]

 

Repeat steps UNTIL
<for>("Counter variable initial value","Condition","Counter loop increment")
Available in: Professional edition

This command begins loop that allows macro developer to repeat part of macro (between "for" and "for_end" commands) multiple times. Each "for" command must be followed by "for_end" command. Each loop, a condition defined in "for" command is evaluated and if it is evaluated as "not true" then the "for" loop is ended. It is possible to end the "for" loop also using "for_break" command.

 

#

Parameter name

Parameter description

1

Counter variable initial value

Counter variable initialization in form "Variable = value". Example: "varCounter = 1".

2

Condition

Condition in the same form as in "if_..." command. Example: "%varCounter% < 100".

3

Counter loop increment

The value that defines how to increase the counter value each loop. Example: "1".

 

Example (Macro Steps):

 

1

<#> <#> This macro shows how to use "for" loop.

2

<#> <#> There are two embedded "for" loops.

3

<#> <#>

4

Macro execution: ONLY COMMANDS

5

Repeat steps UNTIL "vX < 5" (Counter variable initial value = "vX=1", Counter loop increment = "1")

6

Repeat steps UNTIL "vY < 5" (Counter variable initial value = "vY=1", Counter loop increment = "1")

7

Message SHOW "Information" : "Counters [x,y] = [%vX%,%vY%] Press F10' to exit this macro." (other parameters: x = -100, y = -100, Window title = For Counters, Buttons = None, Timeout (seconds) = 0, Always on top = ).

8

Error message DISABLED

9

WAIT FOR Object = "KEY", Event = "PRESS", Parameter = "", Timeout (seconds) = "1", Exact = "0"

10

Error CLEAR

11

Error message ENABLED

12

If KEY / MOUSE BUTTON "" is "Down" then execute following steps

13

Macro EXIT

14

ENDIF

15

Repeat steps END

16

Repeat steps END

Example (Plain Text):

 

<#> This macro shows how to use "for" loop.

<#> There are two embedded "for" loops.

<#>

<cmds>

 

<for>("vX=1","vX < 5","1")

 

<for>("vY=1","vY < 5","1")

 

<msg>(-100,-100,"Counters [x,y] = [%vX%,%vY%]

 

Press F10' to exit this macro.","For Counters",0,0,0)

 

<me_error_nodisplay> <waitfor>("KEY","PRESS","<F10>",1,0)<me_error_clear><me_error_display>

 

<if_key>("<F10>","DOWN")

<exitmacro>

<endif>

 

<for_end>

 

<for_end>