Thanks Greg, I tested your solution and it is running perfectly.
Personally I don't like so much the idea to duplicate the screen but who cares? At the eyes of a final user that will use the macro this solution is optimal as it is completely transparent, my first idea to use a second useless-prompt was not so clean for the users.
Thanks again.
Original Message:
Sent: Tue November 18, 2025 04:02 PM
From: Greg Cornett
Subject: HAScript
ChatGPT gave me clues about HAScript prompting and I think I was able to figure it out.
Once a prompt has been answered, HAScript recognizes that as a "completed" prompt, and it will not display the same prompt again. But, as soon as you start another prompt with a different name, HAScript forgets all about the previous prompt.
So what I did was change your script from a two screen script to a four screen script, where 1 and 3 are duplicates and 2 and 4 are duplicates. The only difference between 1 and 3 is where I added an innocuous extra space at the end of the prompt name so the HAScript would recognize it as two different prompts.
Screen1:
<prompt name="'Customer code'"
Screen3:
<prompt name="'Customer code '" (See the extra space added at the end?)
That is enough to reset the loop. The prompt on Screen3 makes it forget the prompt on Screen1, and then after it loops the prompt on Screen1 makes it forget about the prompt on Screen3. Here is the script I ended up with.
<HAScript name="test_prompt"
description=""
timeout="60000"
pausetime="300"
promptall="false"
blockinput="true"
author=""
creationdate=""
supressclearevents="false"
usevars="true"
ignorepauseforenhancedtn="true"
delayifnotenhancedtn="0"
ignorepausetimeforenhancedtn="true"
continueontimeout="false">
<vars>
<create name="$CustomerCode$" type="string" value="" />
</vars>
<screen name="Schermo1" entryscreen="true" exitscreen="false" transient="false">
<description>
<oia status="NOTINHIBITED" />
</description>
<actions>
<!-- clear variable so prompt appears every time -->
<varupdate name="$CustomerCode$" value="" />
<!-- send 'S' as in your original script -->
<input value="'S'" row="0" col="0" movecursor="true" />
<!-- this prompt will show every loop until user presses Cancel -->
<prompt name="'Customer code'"
row="9" col="33" len="9"
required="true"
title="'Customer code'"
assigntovar="$CustomerCode$"
varupdateonly="false"
clearfield="true" />
<!-- If user presses Cancel, the script simply stops here (your desired behavior). -->
<!-- Confirm (press ENTER) -->
<input value="'[enter]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</actions>
<nextscreens>
<nextscreen name="Schermo2" />
</nextscreens>
</screen>
<screen name="Schermo2" entryscreen="false" exitscreen="false" transient="false">
<description>
<oia status="NOTINHIBITED" />
<numfields number="272" optional="true" />
<numinputfields number="0" optional="true" />
</description>
<actions>
<!-- Move down and exit -->
<input value="'[down][down][down][pf7]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</actions>
<nextscreens>
<nextscreen name="Schermo3" />
</nextscreens>
</screen>
<screen name="Schermo3" entryscreen="true" exitscreen="false" transient="false">
<description>
<oia status="NOTINHIBITED" />
</description>
<actions>
<!-- clear variable so prompt appears every time -->
<varupdate name="$CustomerCode$" value="" />
<!-- send 'S' as in your original script -->
<input value="'S'" row="0" col="0" movecursor="true" />
<!-- this prompt will show every loop until user presses Cancel -->
<prompt name="'Customer code '"
row="9" col="33" len="9"
required="true"
title="'Customer code'"
assigntovar="$CustomerCode$"
varupdateonly="false"
clearfield="true" />
<!-- If user presses Cancel, the script simply stops here (your desired behavior). -->
</actions>
<!-- Confirm (press ENTER) -->
<input value="'[enter]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
<nextscreens>
<nextscreen name="Schermo4" />
</nextscreens>
</screen>
<screen name="Schermo4" entryscreen="false" exitscreen="false" transient="false">
<description>
<oia status="NOTINHIBITED" />
<numfields number="272" optional="true" />
<numinputfields number="0" optional="true" />
</description>
<actions>
<!-- Move down and exit -->
<input value="'[down][down][down][pf7]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</actions>
<nextscreens>
<!-- go back and prompt again -->
<nextscreen name="Schermo1" />
</nextscreens>
</screen>
</HAScript>
------------------------------
Greg Cornett
------------------------------
Original Message:
Sent: Tue November 18, 2025 12:52 PM
From: Costantino Beretta
Subject: HAScript
Sure here is the code of a macro I wrote to see the problem.
If I uncomment the second prompt everything work as expected (but I need to insert two times the customer-code) if I left only one prompt, the macro will loop forever using the code I inserted in the prompt the first time.
<HAScript name="test_prompt"
description=""
timeout="60000"
pausetime="300"
promptall="false"
blockinput="true"
author=""
creationdate=""
supressclearevents="false"
usevars="true"
ignorepauseforenhancedtn="true"
delayifnotenhancedtn="0"
ignorepausetimeforenhancedtn="true"
continueontimeout="false">
<screen name="Schermo1" entryscreen="true" exitscreen="false" transient="false">
<description >
<oia status="NOTINHIBITED" optional="false" invertmatch="false" />
</description>
<actions>
<!-- Select function (press "S")-->
<input value="'S'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
<!-- Ask user for customer code -->
<prompt name="'Customer code'" description="" row="9" col="33" len="9" default="" clearfield="true" encrypted="false" movecursor="false" xlatehostkeys="true" assigntovar="" varupdateonly="false" required="true" title="'Customer code'" />
<!--
<prompt name="'Customer code 2'" description="" row="9" col="33" len="9" default="" clearfield="true" encrypted="false" movecursor="false" xlatehostkeys="true" assigntovar="" varupdateonly="false" required="true" title="'Customer code'" />
-->
<!-- Confirm (press ENTER) -->
<input value="'[enter]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</actions>
<nextscreens timeout="0" >
<nextscreen name="Schermo2" />
</nextscreens>
</screen>
<screen name="Schermo2" entryscreen="false" exitscreen="false" transient="false">
<description >
<oia status="NOTINHIBITED" optional="false" invertmatch="false" />
<numfields number="272" optional="true" invertmatch="false" />
<numinputfields number="0" optional="true" invertmatch="false" />
</description>
<actions>
<!-- Move down and exit -->
<input value="'[down][down][down][pf7]'" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
</actions>
<nextscreens timeout="0" >
<nextscreen name="Schermo1" />
</nextscreens>
</screen>
</HAScript>
------------------------------
--
Costantino Beretta
Original Message:
Sent: Tue November 18, 2025 10:37 AM
From: Greg Cornett
Subject: HAScript
Can you share the script?
------------------------------
Greg Cornett