Jump to content
Macro Express Forums

Challenge: Insert boilerplate text into a field in a database


Recommended Posts

Due to a disability, an employee operates a computer with two fingers on one hand.

 

As part of his job in a call centre, the employee makes about 40 telephone calls per day. After each call, he documents it by entering a note into a field in a database.

 

There are five different notes he enters into the field:

 

- I reached the client and explained the issue. I will follow up by mail.

- I left a voice mail message requesting a call back.

- I left a message with the person who answered the phone and asked that the client call me.

- The telephone number is not in service. I will send a letter.

- The client does not have telephone service. I will send a letter.

 

Several years ago, the employee typed the five notes into a Word document, one note per paragraph. Now, he leaves this document open while on the phone. After making a call, he selects one of the five paragraphs, copies it, switches to the database, and pastes the text in the field.


The challenge is to automate the task of entering the appropriate note into the database field.


You can assume that when the field has focus, text can be typed, pasted, selected, and navigated around using standard navigation keys and by pointing and clicking.

 

I came up with two different macro solutions, but I prefer one over the other because there is less to memorize. I'm curious how others will approach the same challenge!

Link to comment
Share on other sites

Cory, your solution is more or less the same as my first effort. But then I had another idea -- to be revealed after others have chimed in with their solutions.

 

The employee types with two fingers on one hand, so hotkeys that involve modifier keys (Ctrl, Alt, etc.) take more effort than macros that are activated by pressing single keys. I add, parenthetically, that his upper body mobility and strength are somewhat limited, so the function keys are a bit of long stretch for him.

 

Good question about the database's built-in hotkeys. Assume that there are no keyboard shortcuts of consequence; and even if there are, the employee prefers to drive the application by mouse.

 

Link to comment
Share on other sites

The first thing I would do is get rid of the Word document.  With text that short, it could just be embedded in the macro in Text Type commands.  However, having the document makes it easy for the user to modify his text without having to involve a macro coder, so let’s keep Word involved.  But modify the Word document so paragraphs are delineated by some simple character sequence such as ***.  

 

So the Word document is:
***I reached the client and explained the issue. I will follow up by mail.
***I left a voice mail message requesting a call back.
***I left a message with the person who answered the phone and asked that the client call me.
***The telephone number is not in service. I will send a letter.
***The client does not have telephone service. I will send a letter.
***   

 

The user would toggle to Word – actually I’d probably give him a macro to do the toggle – then use arrow keys to move anywhere within the paragraph to be selected, and start the macro with a key combination.  The macro would then arrow back through the text until *** is located, determining the beginning of the paragraph.  Then copy all text forward from that point into the clipboard, and select out the desired paragraph by scanning for the next *** (end of paragraph).  Then the macro would switch to the database screen, tab to the proper field, and type or paste the variable containing the captured paragraph.  

 

Another method, for ease of two-finger use, would be to dispatch one of five “driver” macros using keys 1 through 5 of the keypad.  Each macro corresponds to selecting one of the five paragraphs.  A common called macro would then switch to Word, copy the entire Word document to the clipboard, and select out the desired text delineated by counting *** sequences.  Then switch to the database screen and type or paste.  

 

I like the second method for ease of use, but it requires the user to memorize the paragraph number of each possible text selection.  The first method is more flexible if there are too many paragraphs to commit to memory, or if they change often in number or content so memory isn’t feasible.  As it has been years since the user has had to change text, he should have committed it to memory by now, so I’d go with method 2 though philosophically I like 1 better.  

 

Could also do this with a multiple choice menu, which does away with the user’s need to memorize, and also does away with most of the coding.      

 

Link to comment
Share on other sites

That's the first time I've encountered the word "troglodyte" in ages! What a fine word.

 

Interesting idea to use the Word document as a source file. This would make things easier to maintain, which might be an important benefit.

 

If you try to code it, here's a clue: If the text to be transferred is in its own paragraph, you don't need to delimit it with *** or anything else. In Word, pressing F8 four times automatically selects the current paragraph.

 

(Edit: F8 selects to the next typed character, digit, or symbol. F8 x 2 selects the word, F8 x 3 selects the sentence, F8 x 4 selects the paragraph, and F8 x 5 selects the section, and F8 x 6 selects the document. If there are no sections, five times selects the document.)

Edited by acantor
Link to comment
Share on other sites

10 hours ago, acantor said:

In Word, pressing F8 four times automatically selects the current paragraph.

Well, you learn something every day.  Thanks, never knew that. 

Once the paragraph is selected, mouse operations seem to be affected.  Clicking somewhere after the selected paragraph adds the intervening text to the selection.  Haven't figured out how to turn it off once it has been turned on. 

Link to comment
Share on other sites

Like Cory, I’d simply go for five macros. Maybe activated by shortkeys if focus is already in the target field and that’s easier for your user. Perhaps I’ve missed something but, if it really is just a matter of choosing one of a mere five options, which have been in use for a long time, then it seems a relatively trivial challenge.

 

If, as I think you implied, he favours mouse over keys then perhaps an alternative of clicking in an image that’s always on-screen?

List-1.jpg

Link to comment
Share on other sites

1 hour ago, rberq said:

Well, you learn something every day.  Thanks, never knew that. 

Once the paragraph is selected, mouse operations seem to be affected.  Clicking somewhere after the selected paragraph adds the intervening text to the selection.  Haven't figured out how to turn it off once it has been turned on. 

 

Right click outside the text.

 

An alternative for selecting the para is <Ctrl+Shift+Arrow Down>

 

Link to comment
Share on other sites

When in "select mode" in Word, exit the mode by performing any operation that acts on the selection (e.g., copy, underline, etc.) or by pressing Esc.

 

Pressing Esc does not deselect the text. But once you have exited select mode, you can press the right arrow to position the cursor to the right of the (formerly) selected text, or left arrow to position the cursor to the left of it.

Link to comment
Share on other sites

5 hours ago, terrypin said:

Perhaps I’ve missed something but, if it really is just a matter of choosing one of a mere five options, which have been in use for a long time, then it seems a relatively trivial challenge.

 

I'll post my solution soon, which is very different than any solution proposed so far.

 

Terry, I like your idea of the clickable images of the texts! Can it be done in Macro Express?

Link to comment
Share on other sites

43 minutes ago, acantor said:

 

I'll post my solution soon, which is very different than any solution proposed so far.

 

Terry, I like your idea of the clickable images of the texts! Can it be done in Macro Express?


Sure it can. In fact I wrote a macro to test the approach before my earlier post. It displayed the text of the selected choice in a TBD. I stopped there though, as it really did seem overkill compared with simply clicking a hotkey. It was just a series of seven IFs. After waiting for a mouse click, the mouse positions were captured. Five IFs tested for the Y coordinate being within each of the text areas. The other two checked if that value was beyond the top or bottom of the whole text area and if so alerted the user and asked him to click again. An obvious restriction is that no other left mouse clicks can occur. So for example responding to theTBD in my test macro had to be by pressing Enter rather than clicking OK. Of course,  that shortcoming could be avoided or minimised by right clicking (or less comfortably middle clicking) the text area.

 

 

Link to comment
Share on other sites

How about an accessory macro keyboard. Gamers and professionals who use complex programs love 'em. Some add rows of keys above the normal keys in a keyboard, sme have a separate pad of 16 or so keys. Many accessibility oriented. Some a USB "key strips". The keys can be programmed to do anything and some even have caps that are backlit that can be removed so you can make your own art and drop it in printing to a transparency with a laser printer. 

Also there are many great keyboards, mice, and such for impaired people. I was looking at the foot operated mice earlier today. I'm not suggesting it in this case, ubt just letting you know there are some amazing things. And recently I read of a company that has a reasonably priced, less than $200 I think, eye motion tracker and input device where one can point the mouse cursor by looking at something on the screen and long-blinking to click. 

Anyway, there's tons of great hardware and the ones with programmable keys could be programed to fire MEP macros. 

Link to comment
Share on other sites

13 hours ago, rberq said:

Once the paragraph is selected, mouse operations seem to be affected.  Clicking somewhere after the selected paragraph adds the intervening text to the selection.  Haven't figured out how to turn it off once it has been turned on. 

 

It's not that mouse operations are affected, but that select mode is ON> So when you click after the selected text, the intervening text gets included  as part of the selection.

 

Which means Word supports another way to select text in a document. Click at the start of where you want to start selecting. Press F8. Click at the end of the selection. Done.

Link to comment
Share on other sites

When I set the challenge, I said the boilerplate text is inserted into a field in the database, and that while the field is focused, "text can be typed, pasted, selected, and navigated around using standard navigation keys and by pointing and clicking."

 

My solution takes advantage of something that many (perhaps most) computer users recognize: when you select text in a document, and then start typing, the selected text is immediately replaced by the typed characters.

 

My solution consists of one macro activated by a hotkey.

 

To begin, the employee clicks into the field that will receive the note.

 

He presses the hotkey.

 

The macro inserts the first note into the field, and then automatically selects the entire field by sending Ctrl + A (the standard hotkey to select an entire document... or an entire field.)

 

If the note is the one he wants, the macro’s work is done, and the employee moves on to the next task.

 

But if it’s not the right note, he presses the hotkey again. The second note overwrites the first note, and it is selected.

 

He continues to press the hotkey until the correct note appears. After the fifth note, the macro cycles back to the first note.

 

I like this solution because there’s only one hotkey to memorize.

 

But there is a drawback to this approach: If he presses the hotkey one time too many, he has to press it four more times to get back to the text he wants. I think this is acceptable because there are only five texts. But if there were 10 or 20 different boilerplate texts to cycle through instead of five, this approach might get tiresome.

 

// Cycle through five pre-defined texts, %Text1% - %Text5%, and insert into a field.
// Each time text is inserted, the entire field is selected.
// When the macro is activated again, a new text replaces the old.
 
// The first time the macro is activated, insert %Text1%.
// The second time the macro is activated, insert %Text2%.
// etc.
// The sixth time the macro is activated, reset counter %x% to 1, which restarts the cycle with %Text1%.
 
// Counter %x% tracks which text was last inserted. 
// The value of %x% is saved each time the macro completes, and restored each time the macro starts:
 
Variable Restore: Restore Integer Variables
 
// Here are the five pre-defined texts:
Variable Set String %Text1% to "Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. "
Variable Set String %Text2% to "Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. "
Variable Set String %Text3% to "The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. "
Variable Set String %Text4% to "Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. "
Variable Set String %Text5% to "This is 5 and soon it will be time for another number that is not 5."
 
// Reset counter to 1 when %x% > 5. Its value is zero the first run, so deal with that.
If Variable %x% Is Greater Than "5"
  OR
If Variable %x% Equals "0"
  Variable Set Integer %x% to 1
End If
 
// Output %Text1%, %Text2%, etc.
Text Type (Use Clipboard and Paste Text): %Text%x%% // Pasting is faster than typing out the text.
 
// Select the entire field. Alternative: Shift + Ctrl + Home.
Text Type (Simulate Keystrokes): <CONTROL>a
 
// Increment the counter.
Variable Modify Integer %x%: Increment
 
Variable Save: Save Integer Variables

<COMMENT Value="Cycle through five pre-defined texts, %Text1% - %Text5%, and insert into a field."/>
<COMMENT Value="Each time text is inserted, the entire field is selected."/>
<COMMENT Value="When the macro is activated again, a new text replaces the old."/>
<COMMENT/>
<COMMENT Value="The first time the macro is activated, insert %Text1%."/>
<COMMENT Value="The second time the macro is activated, insert %Text2%."/>
<COMMENT Value="etc."/>
<COMMENT Value="The sixth time the macro is activated, reset counter %x% to 1, which restarts the cycle with %Text1%."/>
<COMMENT/>
<COMMENT Value="Counter %x% tracks which text was last inserted. "/>
<COMMENT Value="The value of %x% is saved each time the macro completes, and restored each time the macro starts:"/>
<COMMENT/>
<VARIABLE RESTORE Option="\x02"/>
<COMMENT/>
<COMMENT Value="Here are the five pre-defined texts:"/>
<VARIABLE SET STRING Option="\x00" Destination="%Text1%" Value="Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. Text 1 is here. " NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%Text2%" Value="Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. Text 2 is also nice. " NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%Text3%" Value="The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. The third example is 3. " NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%Text4%" Value="Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. Number 4. " NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%Text5%" Value="This is 5 and soon it will be time for another number that is not 5." NoEmbeddedVars="FALSE"/>
<COMMENT/>
<COMMENT Value="Reset counter to 1 when %x% > 5. Its value is zero the first run, so deal with that."/>
<IF VARIABLE Variable="%x%" Condition="\x03" Value="5" IgnoreCase="FALSE"/>
<OR/>
<IF VARIABLE Variable="%x%" Condition="\x00" Value="0" IgnoreCase="FALSE"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%x%" Value="1"/>
<END IF/>
<COMMENT/>
<COMMENT Value="Output %Text1%, %Text2%, etc."/>
<TEXT TYPE Action="1" Text="%Text%x%%" _COMMENT="Pasting is faster than typing out the text."/>
<COMMENT/>
<COMMENT Value="Select the entire field. Alternative: Shift + Ctrl + Home."/>
<TEXT TYPE Action="0" Text="<CONTROL>a"/>
<COMMENT/>
<COMMENT Value="Increment the counter."/>
<VARIABLE MODIFY INTEGER Option="\x07" Destination="%x%"/>
<COMMENT/>
<VARIABLE SAVE Option="\x02"/>

 

Link to comment
Share on other sites

Morning Alan,

 

Nice! And that cycling idea could be used quite widely to advantage in a variety of macro applications I suspect. With more numerous options, another hotkey (or two) could be used to toggle a brisk (or fast) speed, with Space to stop it at the correct choice.

 

But I think that tapping one of five keys would be easier. And a small strip of laminated card showing the choices would do just as good a job as my image method, without sacrificing screen space. A card with #00 to #99 shortkeys, scoped to this app for a hundred choices would open more versatile possibilities.

 

Terry

Sunday 30 August 2020, 0808

 

 

Link to comment
Share on other sites

16 hours ago, Cory said:

How about an accessory macro keyboard. Gamers and professionals who use complex programs love 'em.

 

Most of the organizations I support are happy to install Macro Express on the computers of employees with disabilities. The macros help these organizations meet their legal duty to accommodate.

 

But some sectors are very security conscious. No software or hardware can be installed on their computers unless the product is certified. The certification process is strict. These organizations are highly motivated to avoid data breaches.

 

In these security-conscious environments that have not certified Macro Express, I use external programmable keypads, which some organizations have certified. I especially like the X-Keys. Compared to Macro Express, though, the X-Keys is limited in what can be automated. But a programmable keypad would be a good way to meet this challenge: five keys, five macros.

 

If I did this on an X-Keys, I would be tempted to insert the text AND select it. That way, if the employee pressed the wrong button and inserted the incorrect text, all he would have to do is press another keypad key without the need to delete the incorrect text.

Link to comment
Share on other sites

6 hours ago, terrypin said:

But I think that tapping one of five keys would be easier.

 

Hi Terry, You might be right! But it's a good thing that there are many potential solutions.

 

rberq's idea of storing the texts in a file still intrigues me. It would be useful if the person who needs this system is able to maintain it without the need to edit macros. Instead, the user edits a text file, saves it, and the next time the macro is activated, the texts have been updated.

Link to comment
Share on other sites

Here is a refinement.

 

In this version, the five texts are saved in a plain text file, which will allow the user to edit the texts. In the file, each text must be wrapped in quote marks, and there must be a Tab character between the texts.

 

Quote

"I reached the client and explained the issue. I will follow up by mail."[TAB]"I left a voice mail message requesting a call back."[TAB]"I left a message with the person who answered the phone and asked that the client call me."[TAB]"The telephone number is not in service. I will send a letter."[TAB]"The client does not have telephone service. I will send a letter."

 

Note 1. You must substitute a press of the Tab key for each [TAB] in the file.)

 

Note 2. When saving the file, make sure the encoding is set to "ANSI" not "UTF..."

 

The scripts appears in the next message...

 

 

Link to comment
Share on other sites

 

// Cycle through five pre-defined texts, %Text[1]% - %Text[5]%, and insert into a field.
// Each time text is inserted, the field gets selected.
// When the macro is activated again, the next text in the cycle replaces the old.
 
// The first time the macro is activated, insert %Text[1]%.
// The second time the macro is activated, insert %Text[2]%.
// etc.
// The sixth time the macro is activated, reset the counter to 1, which restarts the cycle with %Text[1]%.
 
// Counter %x% tracks which text was last inserted. 
// The value of %x% is saved each time the macro completes, and restored each time the macro starts:
Variable Restore: Restore Integer Variables
 
// The pre-defined texts are stored in an ANSI-encoded text file.
// Each of the five texts must be wrapped in quotation marks.
// There must be a Tab character between each text. So the file looks something like this:
// "1. Hi there."<TAB>"2. Goodbye!"<TAB> etc.
 
// The five pre-defined texts are imported into this script every time it's run:
ASCII File Begin Process: "C:\Tmp\Test.txt" (Tab Delimited Text (.txt))
ASCII File End Process
 
// Reset the counter to 1 when %x% > 5. Its value is zero the first run, so deal with that.
If Variable %x% Is Greater Than "5"
  OR
If Variable %x% Equals "0"
  Variable Set Integer %x% to 1
End If
 
// Output %Text[1]%, %Text[2]%, etc.
Text Type (Use Clipboard and Paste Text): %Text[%x%]%
 
// Select the entire field. Alternative: Shift + Ctrl + Home.
Text Type (Simulate Keystrokes): <CONTROL>a
 
// Increment the counter.
Variable Modify Integer %x%: Increment
 
Variable Save: Save Integer Variables

<COMMENT Value="Cycle through five pre-defined texts, %Text[1]% - %Text[5]%, and insert into a field."/>
<COMMENT Value="Each time text is inserted, the field gets selected."/>
<COMMENT Value="When the macro is activated again, the next text in the cycle replaces the old."/>
<COMMENT/>
<COMMENT Value="The first time the macro is activated, insert %Text[1]%."/>
<COMMENT Value="The second time the macro is activated, insert %Text[2]%."/>
<COMMENT Value="etc."/>
<COMMENT Value="The sixth time the macro is activated, reset the counter to 1, which restarts the cycle with %Text[1]%."/>
<COMMENT/>
<COMMENT Value="Counter %x% tracks which text was last inserted. "/>
<COMMENT Value="The value of %x% is saved each time the macro completes, and restored each time the macro starts:"/>
<VARIABLE RESTORE Option="\x02"/>
<COMMENT/>
<COMMENT Value="The pre-defined texts are stored in an ANSI-encoded text file."/>
<COMMENT Value="Each of the five texts must be wrapped in quotation marks."/>
<COMMENT Value="There must be a Tab character between each text. So the file looks something like this:"/>
<COMMENT Value="\"1. Hi there.\"<TAB>\"2. Goodbye!\"<TAB> etc."/>
<COMMENT/>
<COMMENT Value="The five pre-defined texts are imported into this script every time it's run:"/>
<ASCII FILE BEGIN PROCESS Filename="C:\\Tmp\\Test.txt" Format="Tab" Start_Record="1" Process_All="TRUE" Records="1" Variable="%Text%" Start_Index="1" Parse_Blank_Lines="FALSE" Clear_Array="FALSE"/>
<ASCII FILE END PROCESS/>
<COMMENT/>
<COMMENT Value="Reset the counter to 1 when %x% > 5. Its value is zero the first run, so deal with that."/>
<IF VARIABLE Variable="%x%" Condition="\x03" Value="5" IgnoreCase="FALSE"/>
<OR/>
<IF VARIABLE Variable="%x%" Condition="\x00" Value="0" IgnoreCase="FALSE"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%x%" Value="1"/>
<END IF/>
<COMMENT/>
<COMMENT Value="Output %Text[1]%, %Text[2]%, etc."/>
<TEXT TYPE Action="1" Text="%Text[%x%]%"/>
<COMMENT/>
<COMMENT Value="Select the entire field. Alternative: Shift + Ctrl + Home."/>
<TEXT TYPE Action="0" Text="<CONTROL>a"/>
<COMMENT/>
<COMMENT Value="Increment the counter."/>
<VARIABLE MODIFY INTEGER Option="\x07" Destination="%x%"/>
<COMMENT/>
<VARIABLE SAVE Option="\x02"/>

 

Link to comment
Share on other sites

Hopefully this is the final refinement!

 

Once I had a script to insert the texts in sequence, it seemed reasonable to make a second script to insert the texts in reverse order. I have assigned Keypad period to go forward, and Keypad zero to go backward.

 

In actual use, press the Forward key to cycle forward. Text 1 --> Text 2 --> ...--> Text 5 --> Text 1...

 

Press the Backward key to cycle in reverse: Text 1 --> Text 5 --> Text 4...

 

FORWARD:

// Cycle FORWARDS through five pre-defined texts, %Text[1]% - %Text[5]%, and insert into a field.
// Each time text is inserted, the field gets selected.
// When the macro is activated again, the next text in the cycle replaces the old.
 
// The first time the macro is activated, insert %Text[1]%.
// The second time the macro is activated, insert %Text[2]%.
// etc.
// The sixth time the macro is activated, reset the counter to 1, which restarts the cycle with %Text[1]%.
 
// Counter %x% tracks which text was last inserted. 
// The value of %x% is saved each time the macro completes, and restored each time the macro starts:
Variable Restore: Restore Integer Variables
 
// Increment the counter.
Variable Modify Integer %x%: Increment
 
// Reset the counter to 1 when %x% > 5. Its value is zero the first run, so deal with that.
If Variable %x% Is Greater Than "5"
  OR
If Variable %x% Equals "0"
  Variable Set Integer %x% to 1
End If
 
// The pre-defined texts are stored in an ANSI-encoded text file.
// Each of the five texts must be wrapped in quotation marks.
// There must be a Tab character between each text. So the file looks something like this:
// "1. Hi there."<TAB>"2. Goodbye!"<TAB> etc.
 
// The five pre-defined texts are imported into this script every time it's run:
ASCII File Begin Process: "C:\Tmp\Test.txt" (Tab Delimited Text (.txt))
ASCII File End Process
 
// Output %Text[1]%, %Text[2]%, etc.
Text Type (Use Clipboard and Paste Text): %Text[%x%]%
 
// Select the entire field. Alternative: Shift + Ctrl + Home.
Text Type (Simulate Keystrokes): <CONTROL>a
 
Variable Save: Save Integer Variables

<COMMENT Value="Cycle FORWARDS through five pre-defined texts, %Text[1]% - %Text[5]%, and insert into a field."/>
<COMMENT Value="Each time text is inserted, the field gets selected."/>
<COMMENT Value="When the macro is activated again, the next text in the cycle replaces the old."/>
<COMMENT/>
<COMMENT Value="The first time the macro is activated, insert %Text[1]%."/>
<COMMENT Value="The second time the macro is activated, insert %Text[2]%."/>
<COMMENT Value="etc."/>
<COMMENT Value="The sixth time the macro is activated, reset the counter to 1, which restarts the cycle with %Text[1]%."/>
<COMMENT/>
<COMMENT Value="Counter %x% tracks which text was last inserted. "/>
<COMMENT Value="The value of %x% is saved each time the macro completes, and restored each time the macro starts:"/>
<VARIABLE RESTORE Option="\x02"/>
<COMMENT/>
<COMMENT Value="Increment the counter."/>
<VARIABLE MODIFY INTEGER Option="\x07" Destination="%x%"/>
<COMMENT/>
<COMMENT Value="Reset the counter to 1 when %x% > 5. Its value is zero the first run, so deal with that."/>
<IF VARIABLE Variable="%x%" Condition="\x03" Value="5" IgnoreCase="FALSE"/>
<OR/>
<IF VARIABLE Variable="%x%" Condition="\x00" Value="0" IgnoreCase="FALSE"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%x%" Value="1"/>
<END IF/>
<COMMENT/>
<COMMENT Value="The pre-defined texts are stored in an ANSI-encoded text file."/>
<COMMENT Value="Each of the five texts must be wrapped in quotation marks."/>
<COMMENT Value="There must be a Tab character between each text. So the file looks something like this:"/>
<COMMENT Value="\"1. Hi there.\"<TAB>\"2. Goodbye!\"<TAB> etc."/>
<COMMENT/>
<COMMENT Value="The five pre-defined texts are imported into this script every time it's run:"/>
<ASCII FILE BEGIN PROCESS Filename="C:\\Tmp\\Test.txt" Format="Tab" Start_Record="1" Process_All="TRUE" Records="1" Variable="%Text%" Start_Index="1" Parse_Blank_Lines="FALSE" Clear_Array="FALSE"/>
<ASCII FILE END PROCESS/>
<COMMENT/>
<COMMENT Value="Output %Text[1]%, %Text[2]%, etc."/>
<TEXT TYPE Action="1" Text="%Text[%x%]%"/>
<COMMENT/>
<COMMENT Value="Select the entire field. Alternative: Shift + Ctrl + Home."/>
<TEXT TYPE Action="0" Text="<CONTROL>a"/>
<COMMENT/>
<VARIABLE SAVE Option="\x02"/>

-----------
  
BACKWARD:
  
// Cycle BACKWARDS through five pre-defined texts, %Text[5]% - %Text[1]% and insert into a field.
// Each time text is inserted, the field gets selected.
// When the macro is activated again, the next text in the cycle replaces the old.
 
// The first time the macro is activated, insert %Text[5]%.
// The second time the macro is activated, insert %Text[4]%.
// etc.
// The sixth time the macro is activated, reset the counter to 5, which restarts the cycle with %Text[5]%.
 
// Counter %x% tracks which text was last inserted. 
// The value of %x% is saved each time the macro completes, and restored each time the macro starts:
Variable Restore: Restore Integer Variables
 
// Decrement the counter.
Variable Modify Integer %x%: Decrement
 
// Reset the counter to 5 when %x% < 1. 
If Variable %x% Is Less Than "1"
  Variable Set Integer %x% to 5
End If
 
// The pre-defined texts are stored in an ANSI-encoded text file.
// Each of the five texts must be wrapped in quotation marks.
// There must be a Tab character between each text. So the file looks something like this:
// "1. Hi there."<TAB>"2. Goodbye!"<TAB> etc.
 
// The five pre-defined texts are imported into this script every time it's run:
ASCII File Begin Process: "C:\Tmp\Test.txt" (Tab Delimited Text (.txt))
ASCII File End Process
 
// Output %Text[5]%, %Text[4]%, etc.
Text Type (Use Clipboard and Paste Text): %Text[%x%]%
 
// Select the entire field. Alternative: Shift + Ctrl + Home.
Text Type (Simulate Keystrokes): <CONTROL>a
 
Variable Save: Save Integer Variables

  
<COMMENT Value="Cycle BACKWARDS through five pre-defined texts, %Text[5]% - %Text[1]% and insert into a field."/>
<COMMENT Value="Each time text is inserted, the field gets selected."/>
<COMMENT Value="When the macro is activated again, the next text in the cycle replaces the old."/>
<COMMENT/>
<COMMENT Value="The first time the macro is activated, insert %Text[5]%."/>
<COMMENT Value="The second time the macro is activated, insert %Text[4]%."/>
<COMMENT Value="etc."/>
<COMMENT Value="The sixth time the macro is activated, reset the counter to 5, which restarts the cycle with %Text[5]%."/>
<COMMENT/>
<COMMENT Value="Counter %x% tracks which text was last inserted. "/>
<COMMENT Value="The value of %x% is saved each time the macro completes, and restored each time the macro starts:"/>
<VARIABLE RESTORE Option="\x02"/>
<COMMENT/>
<COMMENT Value="Decrement the counter."/>
<VARIABLE MODIFY INTEGER Option="\x08" Destination="%x%"/>
<COMMENT/>
<COMMENT Value="Reset the counter to 5 when %x% < 1. "/>
<IF VARIABLE Variable="%x%" Condition="\x02" Value="1" IgnoreCase="FALSE"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%x%" Value="5"/>
<END IF/>
<COMMENT/>
<COMMENT Value="The pre-defined texts are stored in an ANSI-encoded text file."/>
<COMMENT Value="Each of the five texts must be wrapped in quotation marks."/>
<COMMENT Value="There must be a Tab character between each text. So the file looks something like this:"/>
<COMMENT Value="\"1. Hi there.\"<TAB>\"2. Goodbye!\"<TAB> etc."/>
<COMMENT/>
<COMMENT Value="The five pre-defined texts are imported into this script every time it's run:"/>
<ASCII FILE BEGIN PROCESS Filename="C:\\Tmp\\Test.txt" Format="Tab" Start_Record="1" Process_All="TRUE" Records="1" Variable="%Text%" Start_Index="1" Parse_Blank_Lines="FALSE" Clear_Array="FALSE"/>
<ASCII FILE END PROCESS/>
<COMMENT/>
<COMMENT Value="Output %Text[5]%, %Text[4]%, etc."/>
<TEXT TYPE Action="1" Text="%Text[%x%]%"/>
<COMMENT/>
<COMMENT Value="Select the entire field. Alternative: Shift + Ctrl + Home."/>
<TEXT TYPE Action="0" Text="<CONTROL>a"/>
<COMMENT/>
<VARIABLE SAVE Option="\x02"/>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...