Using Text String Variables

 

Below is an example of using Text String Variables. There are hundreds, even thousands of uses for Text String Variables. This example provides an idea of how they can be used and manipulated.

 

This macro, when completed, fixes typing transposition errors such as "adn" or "teh" instead of "and" or "the". Just place the cursor between the two transposed letters and press the assigned hot key to correct the typing error.

 

 


 

 

Setting up the Macro

 

1.From the Macro Express Pro - Explorer menu click on Macro > New Macro to open the Create New Macro window.

2.Hot Key should already be selected as the Activation.

3.Click on the HotKey edit box to place the cursor in this field.

4.Hold down the F4 key and release it.

5.F4 should appear in the edit box. This is the hot key we will define for the macro.

6.Enter "Fix Transposed Letters" (without the quotes) in the Nickname field.

7.Click OK to open the Script Editor. 

8.In the Script Editor click on the Scope tab and make sure that the macro scope is set to global.

9.Click on the Script tab to start building the macro.

 

 

Building the Macro in the Script Editor
 

1.Add a Comment line to the script as a reminder on how to use the macro.

a.  Scroll through the list of command categories and click on Macro Control to expand the list.
b.  Double click on the Comment command.
c.  Type "Place cursor between the transposed letters" (without the quotes) in the Comments Text edit field.
d.  Click OK to save the entry.

The text is displayed in the Script Editor in bold blue font.

 

2.The next step is to highlight the two letters that are reversed using the Text Type command.

a.  Scroll through the list of command categories and click on Keyboard to expand the category.
b.  Double click on Text Type to open the Text Type window. 
c.  Click on Arrow Left from the list of options in the yellow area of this window.
d.  Then click on Shift Down, Arrow Right, Arrow Right and Shift Up.

The entire entry should look like the following:  <ARROW LEFT><SHIFTD><ARROW RIGHT><ARROW RIGHT><SHIFTU>.

e. Click OK to save and return to the Script Editor.

 

3.This next step cuts the highlighted text and copies it to the clipboard.

a.  Scroll through the list of command categories and click on Clipboard to expand the category.
b.  Double click on Clipboard Cut to insert the clipboard cut command as the next item in the script.
 

4.Now save the clipboard contents to a text string variable.

a.  Scroll through the list of command categories and click on Variables to expand the category.
b.  Double click on Variable Set String to open the Variable Set String window.
c.  Select the Set Value from Clipboard option from the drop down menu.
d.  Enter %T[1]% in the Destination Variable field and click OK to save.  

 

5.Save the first letter to a new variable - T[2].

a.  Scroll through the list of command categories and click on Variables to expand the category.
b.  Double click on Variable Modify String to open the Variable Modify String window.
c.  Select Copy Part of Text from the drop down list to copy the first letter of the variable T[1] and save it to variable T[2].
d.  Enter %T[2]% in the Text Variable field and enter %T[1]% the Variable to copy from field.
e.  Enter the number "1" (without the quotations) in the Starting Position field.
f.  In the Number of Characters to Copy field enter the number "1" (without the quotations).
g.  Click OK to save.

 

6.Save the second letter to a separate variable - T[3].

a.  Scroll through the list of command categories and click on Variables to expand the category.
b.  Double click on Variable Modify String to open the Variable Modify String window.
c.  Select the Copy Part of Text option from the drop down list.
d.  Enter %T[3]% in the Text Variable field and enter %T[1]% in the Variable to copy from field.
e.  Enter the number "2" (without the quotations) in the Starting Position field. 
f.  In the Number of Characters to Copy field enter the number "1" (without the quotations).
g.  Click OK to save.

 

7.This last step plays back the corrected text. 

a.  Scroll through the list of command categories and click on Keyboard to expand the category.
b.  Double click on Text Type to open the Text Type window.
c.  In the Keystrokes edit field, type the following: %T[3]%%T[2]%.

This types out the second letter of the transposed text first, reversing the order and correcting the typing error.

d.  Click OK to save and return to the Script Editor.
 

 

Macro Script

The macro script should look like what is displayed below. If the macro doesn't look like this, arrange the commands so that they are in the following order.

 

 

// Place cursor between transposed letters.

Text Type (Simulate Keystrokes): <ARROW LEFT><SHIFTD><ARROW RIGHT><ARROW RIGHT><SHIFTU>

Clipboard Cut

Variable Set String %T[1]% from the clipboard contents

Variable Modify String %T[2]% to a substring in %T[1]% starting at 1 and 1 characters long

Variable Modify String %T[3]% to a substring in %T[1]% starting at 2 and 1 characters long

Text Type (Simulate Keystrokes): %T[3]%%T[2]%

 


Click on Script > Save Macro to save the macro just created.

 

 

Testing the macro

To test the macro, run the notepad program. (Depending on your version of Windows, click on the Windows Start button, enter notepad in the Search field and press enter. Or right click on the Windows Start button, select Run, enter notepad and click OK.)

 

Type the following text into notepad - Tihs is a tset. (Include the typing errors.)

 

Insert the cursor between the "i" and "h" in the word "Tihs". Press the F4 key to play back the macro. The letters are reversed to correct the spelling to "This". Try the same thing with the misspelled word "tset".

 

 

üNote: If assigning original names to variables, rather than using T[1], D[1], etc., then the following characters are not allowed in the variable name:  [ ] < > , . - + = \ | / * %