Commands & Syntax > Commands > Variable Manipulation >

SET - < varset >() ... [Pro]

www.perfectkeyboard.com

 

Variable SET
<varset>("Variable","Message text")
Available in: Professional edition

Declares variable and sets its value.

 

#

Parameter name

Parameter description

1

Variable

Defines variable and its value in the form "variable=VALUE". Variable can be any string (different from system variables). The value can be either constant string or other variable or empty string. There are four basic behaviors of the command:

1.VALUE is supplied. In such case the variable is assigned the VALUE. For example, "vNumber=10" or "vName=John".

2.List of possible values is supplied in VALUE. Each single item in the list is separated by "_OR_" ("|" delimiter character is depricated since version 8.1.0). For example, "vNames=Jane_OR_Paul_OR_Chris_OR_Michael".

3.VALUE is an empty string ("vName="). In such the case, a dialog window with the MessageTitle appears and prompts user to enter the variable value. Note: To assign an empty string to the variable use this construction: "vEmptyStr=_vStrEmpty".

4.VALUE is equal to "YES/NO". In such the case, a "yes/no" message box withMessageTitle appears. If user selects "yes" button the "YES" value is assigned to the variable. If the user selects "no" button the "NO" value is assigned. For example, "vDoYouWant=YES/NO".

In cases #2 and #3 above, if user clicks "Cancel" button the _vCanceled system variable is set to 1 (otherwise it is 0) to allow macro designer to distinguish between situations when OK or Cancel button was clicked. Instead of using VARIABLE_NAME=VALUE syntax, also VARIABLE_NAME=!VALUE can be used. In this case, the VALUE is assigned to the variable and the rules #2 - #4 above are not applied (hard assignement).

2

Message text

A title of the window that appears in cases 1 and 3 above.

 

Example (Macro Steps):

 

1

<#> <#> This macro demonstrates command

2

Macro execution: ONLY COMMANDS

3

Variable SET "vName=", Message text="Insert Your Name"

4

IF STRING _vCanceled==1

5

Macro EXIT

6

ENDIF

7

Variable SET "vShow=YES/NO", Message text="Do you want to see your name ?"

8

IF STRING vShow==YES

9

Message SHOW "" : "vName" (other parameters: x = 100, y = 100, Window title = Your name is:, Buttons = OK, Timeout (seconds) = , Always on top = ).

10

ENDIF

11

Variable SET "vName=Jane_OR_Paul_OR_Michael_OR_Chris", Message text="Who is my best friend ?"

12

IF STRING _vCanceled==1

13

Macro EXIT

14

ENDIF

15

IF STRING vName==Jane

16

Message SHOW "" : "Yes!" (other parameters: x = 100, y = 100, Window title = Message, Buttons = OK, Timeout (seconds) = , Always on top = ).

17

ELSE activate

18

Message SHOW "" : "No!" (other parameters: x = 100, y = 100, Window title = Message, Buttons = OK, Timeout (seconds) = , Always on top = ).

19

ENDIF

Example (Plain Text):

 

<#> This macro demonstrates <varset> command

<#>

<cmds>

 

<varset>("vName=","Insert Your Name")

<if_str>("_vCanceled==1") <exitmacro> <endif>

 

<varset>("vShow=YES/NO","Do you want to see your name ?")

 

<if_str>("vShow==YES")

   <msg>(100,100,"vName","Your name is:",1)

<endif>

 

<varset>("vName=Jane_OR_Paul_OR_Michael_OR_Chris","Who is my best friend ?")

<if_str>("_vCanceled==1") <exitmacro> <endif>

 

<if_str>("vName==Jane")

   <msg>(100,100,"Yes!","Message",1)

<else>

   <msg>(100,100,"No!","Message",1)

<endif>