Commands & Syntax > Commands > Variable Manipulation >

OPERATION - < var_oper >() ... [Pro]

www.perfectkeyboard.com

 

Variable OPERATION
<var_oper>(Variable for result,"Input text/variable",Operation,"Parameter 1","Parameter 2","Parameter 3")
Available in: Professional edition

Performs selected operation on input variable (or constant string/value) and saves the result to other variable.

 

#

Parameter name

Parameter description

1

Variable for result

Variable that receives result of the operation.

2

Input text/variable

Either variable or constant text (string, numerical value) to perform operation on.

3

Operation

One of these operations:

CALC_EXPRESSION
- calculates arithmetical expression defined by input. "Parameter 1" tells how many numbers will follow after decimal point.

RANDOM_NUMBER
- generates random number from 0 to "Parameter 1" range.

SELECT_FILE
- shows "Open File" dialog and saves full path of the selected file to "Variable for result". 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.

SELECT_FOLDER
- shows "Select Folder" dialog and saves full path of the selected folder to "Variable for result". 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.

GET_TEXT_FROM_CLIPBOARD
- copies text from clipboard to "Variable for result".

STR_APPEND
- appends the Input to the content of "Variable for result".

STR_LEFT
- characters from begin of the Input (number of characters is given by "Parameter 1") are copied to "Variable for result".

STR_RIGHT
- characters from end of the Input (number of characters is given by "Parameter 1") are copied to "Variable for result".

STR_MID
- characters beginning at "Parameter 1" position (number of characters is given by "Parameter 2") are copied to "Variable for result".

STR_TRIMLEFT
- characters specified in "Parameter 1" are deleted from begin of the Input.

STR_TRIMRIGHT
- characters specified in "Parameter 1" are deleted from end of the Input.

STR_INSERT
- string defined by "Parameter 2" is inserted to Input string to position "Parameter 1".

STR_REPLACE
- In the Input, original string "Parameter 1" is replaced by "Parameter 2".

STR_DELETE
- in the Input, deletes "Parameter 2" (number of characters to delete) characters starting at position "Parameter 1".

STR_FIND
- finds first occurrence of the "Parameter 1" string in the Input. The search is started from "Parameter 2" position. If not found then the "Variable for result" contains -1.

STR_FIND_NOCASE
- finds (case insensitive) first occurrence of the "Parameter 1" string in the Input. The search is started from "Parameter 2" position. If not found then the "Variable for result" contains -1.

STR_UPPER
- converts Input to upper case.

STR_LOWER
- converts Input to lower case.

STR_LENGTH
- returns length of the Input.

STR_GET_CHAR
- returns (in "Variable for result") character from the "Parameter 1" position in the Input. If position is out of the string then the "Variable for result" is empty.

STR_TOGGLE_CASE
- changes upper case to lower case and vice versa.

STR_SENTENCE_CASE
- changes first character on begin of each sentence to upper case.

STR_INTERSPACES
- extra space is added to next to each Input character. Example: "ABC" is changed to "A B C".

STR_FIRST_UPPER
- changes first character of Input to upper case.

TEXT_GET_WORD
- retrieves a word from "Parameter 1" position within Input. Position is counted from 1 (position 1 means the first word). "Parameter 2" contains characters user can exclude from default word delimiters ( ';,\t\n\r?!.:"). This means that if "." is excluded from the delimiters then "www.my7thsite.com" is returned as a single word. Otherwise it is returned as three words.

TEXT_GET_NUMOFWORDS
- return number of words in Input. "Parameter 2" contains characters user can exclude from default word delimiters ( ;,\t\n\r?!.:).

TEXT_GET_LINE
- retrieves one row from the input text (Input parameter). Row is specified by "Parameter 1" line number (line numbers start at 1).

TEXT_GET_NUMOFLINES
- returns number of lines in Input.

TEXT_JUSTIFY
- justifies the Input text so that all lines have the same length defined by "Parameter 1". If the "Parameter 1" is 0 then the length of all lines is the same as the first line.

TEXT_INDENT_LEFT
- removes leading spaces on begin of each row of "Input" text. The number of spaces removed is defined by "Parameter 1". If "Paramater 1" is empty or 0 then all spaces are removed from begin of each row.

TEXT_INDENT_RIGHT
- adds extra spaces on begin of each row in "Input" text. The number of spaces added is defined by "Parameter 1". If "Paramater 1" is empty then 1 space is added.

TEXT_ADDNUMBERING
- justifies and adds numbering to paragraphs of Input text. Paragraphs are delimited by empty line. "Parameter 1" defines width of the justified text. If the "Parameter 1" is -1 the length of all lines is the same as the first line. "Parameter 2" defines numbering style. It can be one of the follows:
"1)", "1.", "1/", "A)", "A.", "A/", "a)", "a.", "a/", "-", "#", "*"
TEXT_CENTER
- centers "Input" text. "Parameter 1" defines width of the text. If "Paramater 1" is 0 or emtpy then the text is centered based on the longest row.

TEXT_UNDERLINE_LIKE
- extra line consisting of "-" characters is added to Input.

TEXT_ALIGN_LEFT
- aligns Input text left by removing spaces on begin of each line.

TEXT_ALIGN_RIGHT
- aligns Input text to right by adding extra spaces on begin of each line. "Parameter 1" defines width of the text. If the "Parameter 1" is €“1 the width is given by the width of the first line.

ARRAY_SORT_STRING
- sorts array (array variable) of strings passed to the command as "Variable for result" parameter. If "Parameter 1" is 1 then sorting is case sensitive. "Parameter 2" (if specified) is delimiter that delimits the input string so that only the part before delimiter is taken for the comparison. Example: If variable string is "Smooth, John, john@e-mail.net" and delimiter is "," only the "Smooth" is used for comparison. If no delimiter is defined whole "Smooth, John, john@e-mail.net" string is used for comparison.

ARRAY_SORT_NUM
- sorts array (array variable) of numbers passed to the command as "Variable for result" parameter. The "Parameter 2" meaning is the same as in ARRAY_SORT_STRING above.

ARRAY_DELETEALLITEMS
- deletes all items of the "Variable for result" array (array variable).

ARRAY_DELETEITEM
- removes specific item from the "Variable for result" array (array variable). "Parameter 1" is an index of the item to remove.

ARRAY_INSERTITEM
- inserts item to defined position in the "Variable for result" array (array variable). "Parameter 1" is new item position and Input is value of the newly inserted item.

ARRAY_FINDITEM
- searches for the specified value (text) in "Parameter 2" array (array variable). "Parameter 1" is an index to start searching from. Input is the text to search for. If an array item matches search criteria then the item index is saved to "Variable for result" variable otherwise "Variable for result" is empty (%v_strEmpty%). The search only succeeds if whole the item value is equal to Input value (matching is case sensitivity).

ARRAY_FINDITEM_NOCASE
- searches for the specified value (text) in "Parameter 2" array (array variable). "Parameter 1" is an index to start searching from. Input is the text to search for. If an array item matches search criteria then the item index is saved to "Variable for result" variable otherwise "Variable for result" is empty (%v_strEmpty%). The search only succeeds if whole the item value is equal to Input value - but matching is not case sensitive.

ARRAY_FINDITEM_PARTIALMATCH
- searches for the specified value (text) in "Parameter 2" array (array variable). "Parameter 1" is an index to start searching from. Input is the text to search for. If an array item matches search criteria then the item index is saved to "Variable for result" variable otherwise "Variable for result" is empty (%v_strEmpty%). The search succeeds if the item value contains Input value (matching is case sensitivity). For example, an array item "jim@InterCTX.com" matches "CTX" Input value.

ARRAY_FINDITEM_PARTIALMATCH_NOCASE
- searches for the specified value (text) in "Parameter 2" array (array variable). "Parameter 1" is an index to start searching from. Input is the text to search for. If an array item matches search criteria then the item index is saved to "Variable for result" variable otherwise "Variable for result" is empty (%v_strEmpty%). The search succeeds if the item value contains Input value - but matching is not case sensitive. For example, an array item "jim@InterCTX.com" matches "interctx" Input value.

ARRAY_SIZE
- returns the highest index of the array with variable set + 1 (example: If the highest index is 12 then the result is 13). The array variable is passed as the Parameter 2.

IS_VAR_DEFINED
- returns 1 if the variable specified in "Parameter 2" is already defined. Otherwise it returns 0.

4

Parameter 1

Parameter that depends on operation.

5

Parameter 2

Parameter that depends on operation.

6

Parameter 3

Parameter that depends on operation.

 

Example (Macro Steps):

 

1

<#> <#> This example converts text in clipboard to upper-case

2

Macro execution: ONLY COMMANDS

3

Variable OPERATION "GET_TEXT_FROM_CLIPBOARD" (Variable for result = vClipboardText, Input text/variable = , Parameter 1 = , Parameter 2 = , Parameter 3 = 0)

4

IF STRING vClipboardText!=_vStrEmpty

5

Variable OPERATION "STR_UPPER" (Variable for result = vClipboardText, Input text/variable = %vClipboardText%, Parameter 1 = , Parameter 2 = , Parameter 3 = 0)

6

Clipboard COPY "vClipboardText"

7

Message SHOW "" : "Text in clipboard is converted to uppercase." (other parameters: x = -100, y = -100, Window title = Message, Buttons = OK, Timeout (seconds) = , Always on top = ).

8

ENDIF

Example (Plain Text):

 

<#> This example converts text in clipboard to upper-case

<#>

<cmds>

<var_oper>(vClipboardText,"",GET_TEXT_FROM_CLIPBOARD,"","", "0")

<if_str>("vClipboardText!=_vStrEmpty")

 

   <var_oper>(vClipboardText,"%vClipboardText%",STR_UPPER,"","", "0")

   <clpput>("vClipboardText")

   <msg>(-100,-100,"Text in clipboard is converted to uppercase.","Message",1)

 

<endif>