Help with macro loop

User-to-User discussion about the PhraseExpress macro programming.
Post Reply
jptheronmd
Posts: 8
Joined: 03 Jan 22, 10:14

Help with macro loop

Post by jptheronmd » 22 Feb 22, 10:39

Code: Select all

{#settemp -name counter -content 1}{#loop {#input -head {#gettemp counter -variablename counter}. Enter Data -single}{#cond -if {#input -head {#gettemp counter -variablename counter}. Enter Data -single} ==  -then {#settemp -name counter -content 99} -else {#settemp -name counter -content {#calc {#gettemp counter -variablename counter}+1 -round 0}}} -count 100}
Hi, I need help with the following code. I am inexperience with macro programming in PE. I am currently using v15.0.94i.

I am attempting to create a loop which will enter a list of data one after the other. The problem I am having is with the end of the loop. The idea is that if you press enter without entering anything in the data field the loop will end and the data printed to the application. The problem is that it is currently functional but I would like the routine to end once the user enters no data. Instead, it is running the final/last loop and enter has to be pressed a second time so that the condition check can ensure that the counter has reached 100.

I would really like ideas to do this more elegantly. In other words, data can be entered sequentially until the counter reaches 100 or the user enters no data (or maybe another option will work better) and the routine ends immediately?

jptheronmd
Posts: 8
Joined: 03 Jan 22, 10:14

Post by jptheronmd » 22 Feb 22, 11:00

Code: Select all

{#settemp -name counter -content 1}{#loop {#input -head {#gettemp counter}. Enter Data -single}{#cond -if {#input -head {#gettemp counter}. Enter Data -single} ==  -then {#settemp -name counter -content 100} -else {#settemp -name counter -content {#calc {#gettemp counter -variablename counter}+1 -round 0}}{#asc 13}} -count 100}
Edit 1. Just added carriage return. Still unable to get rid of "extra" enter to complete entry.

Post Reply