IBM i Access Client Solutions

 View Only
  • 1.  HAScript problem

    Posted Wed September 27, 2023 05:17 PM

    Let me say that this is my first attempt to do anything with HAScript and what I have read in the user guide has left me confused on how to solve this issue.  Once a month I have to run a repetitive job that contains one variable - month number.  Other screen inputs are fixed.  I have managed to create a MAC file which accomplishes my needs but the month number variable only functions if I edit the MAC file and replace the variable in the script.  I can live with it but want to be able to prompt for the value and have it used to replace a field on an input screen.  I have attempted to do a screen prompt asking for the value.  This works but when I hit the 5250 screen that needs this value, nothing is placed on the screen.  There are a total of sixteen screens with the variable needing to be entered on every even number screen.  I started with the one example I could find on the IBM web pages showing an input variable entered and echoed back to the screen but every attempt of mine to make this function fails.

    Is there anyone who has puzzled out how to make this function?  My code follows and was designed to run a report in MAPICS XA.  If I remove screen1 and simply hard code the variable value it functions properly.

    <HAScript name="test xxx" description="input dialog" timeout="60000" pausetime="300" promptall="true" blockinput="false" author="Steven Lukas" creationdate="09/27/2017" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true" continueontimeout="false">

        <vars>
          <create name="$strData$" type="string" value="00" />
        </vars>


        <screen name="Screen1" entryscreen="false" exitscreen="true" transient="false">
            <description >
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
                <prompt name="&apos;Type Month number&apos;" description="" row="0" col="0" len="80" default="" clearfield="false" encrypted="false" movecursor="true" xlatehostkeys="true" assigntovar="$strData$" varupdateonly="true" required="false" title="" />
                <input value="$strData$" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
            </actions>
            <nextscreens timeout="0" >
                <nextscreen name="Screen2" />
            </nextscreens>
            <recolimit value="10000" />
        </screen>

        <screen name="Screen2" entryscreen="true" exitscreen="false" transient="false">
            <description >
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
                <input value="&apos;6[enter]&apos;" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
            </actions>
            <nextscreens timeout="0" >
                <nextscreen name="Screen3" />
            </nextscreens>
        </screen>

        <screen name="Screen3" entryscreen="false" exitscreen="false" transient="false">
            <description >
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
                <numfields number="55" optional="true" invertmatch="false" />
                <numinputfields number="7" optional="true" invertmatch="false" />
            </description>
            <actions>
                <input value="&apos;[tab]n[tab]n[tab]0[tab]1[tab][tab]&apos;" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
                <input value="$strdata$" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
                <input value="&apos;[field+][enter][enter]&apos;" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
            </actions>
            <nextscreens timeout="0" >
            </nextscreens>
        </screen>

    </HAScript>



    ------------------------------
    Steven Lukas
    ------------------------------


  • 2.  RE: HAScript problem

    Posted Wed September 27, 2023 05:35 PM

    IBM's documentation of the HA Scripting language is minimal at best.

    Looks to me like the value you are prompting for is being saved under $strData$

    I see this line later in your script:

    <input value="$strdata$" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />

    "$strData$" is not the same as "$strdata$"

    Try changing that line in your script to:
    <input value="$strData$" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />

    If you need it to enter in a particular location, you can also set the row and column.  I also like to add a mouse click to that location, just to make sure.  For example, to enter the text starting at Row 5, Col 4, try:

    <mouseclick row="5" col="4" />

    <input value="$strData$" row="5" col="4" movecursor="true" xlatehostkeys="true" encrypted="false" />



    ------------------------------
    Greg Cornett
    ------------------------------



  • 3.  RE: HAScript problem

    Posted Thu September 28, 2023 08:26 AM

    I changed the code as you suggested.  I did not attempt to put in any mouse value.  I should also mention that I am using NotePad++ to make these changes.  When I tested the change my cursor arrives at the correct field but the value placed on the screen is 00, which is the initialization value.  MAPICS XA reported an error as a valid month number is required.

    For my next test I replaced the initial value with 03 rather than 00.  I ran the script and when prompted for a month number I entered 04.  The report input screen was reached and a job submitted.  The submission was for month 03 which was the initial value not the entered month.

    One further anomaly is I eventually get a pop up error that my macro has timed out.  The message box shows my macro name and screen3.

    Steven



    ------------------------------
    Steven Lukas
    ------------------------------



  • 4.  RE: HAScript problem

    Posted Thu September 28, 2023 08:45 AM

    What happens if you don't set your $strData$ variable value to anything?  Try removing the "00" when creating the variable:

    <vars>
          <create name="$strData$" type="string" value="" />
    </vars>



    As far as your macro timing out, try changing Screen 3 to be an exit screen, by changing exitscreen="false" to "true".

        <screen name="Screen3" entryscreen="false" exitscreen="true" transient="false">



    ------------------------------
    Greg Cornett
    ------------------------------



  • 5.  RE: HAScript problem

    Posted Thu September 28, 2023 09:17 AM

    Made the changes you suggested.  The macro ends cleanly now.  However, on the report submission screen the month input field was blank and the input screen complained that a valid numeric range was required.

    In the one example I could find (it is on an IBM page) the value input and echoed back to the screen occurred on a single screen.  This is where I found that example - https://www.ibm.com/support/pages/ibm-i-access-client-solutions-5250-macro-scripting  (Example 3)



    ------------------------------
    Steven Lukas
    ------------------------------



  • 6.  RE: HAScript problem

    Posted Thu September 28, 2023 11:29 AM

    My last two ideas...


    Try changing your variable from a string to an integer. It shoud work fine since you are only using numbers.

    <vars>
          <create name="$strData$" type="integer" value="0" />
    </vars>

    Try changing your prompt from required="false" to "true".  The pop-up box will also look nicer if you change the title section.

                <prompt name="&apos;Type Month number&apos;" description="" row="0" col="0" len="80" default="" clearfield="false" encrypted="false" movecursor="true" xlatehostkeys="true" assigntovar="$strData$" varupdateonly="true" required="true" title="&apos;Type Month Number&apos;" />


    Are you always prompting for the current month?  If so, there are ways to have Java automatically pull in the current month number for you.



    ------------------------------
    Greg Cornett
    ------------------------------



  • 7.  RE: HAScript problem

    Posted Thu September 28, 2023 12:20 PM

    I changed the variable to an integer initialized to zero.  I also changed the required and title box's as suggested.  The input window looks better but no value was left on my input screen.  Well actually, I did have a zero appear on my screen.   Next, I changed the code to initialize the variable to a three.  When I ran the macro I entered a 5.  When the screen displayed a 3 was entered.

    Are you doing your HAScript for 3270 or 5250?  I am on 5250.



    ------------------------------
    Steven Lukas
    ------------------------------



  • 8.  RE: HAScript problem

    Posted Fri September 29, 2023 11:33 AM

    I rewrote the script from scratch and also changed the variable name since something strange was going on.  Try this, I think it'll work for you:

    <HAScript name="test xxx" description="" timeout="60000" pausetime="300" promptall="true" blockinput="true" author="Steven Lukas" creationdate="Sep 28, 2023" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true" continueontimeout="false">

        <vars>
          <create name="$Month$" type="string" value="" />
        </vars>


        <screen name="Screen1" entryscreen="true" exitscreen="false" transient="false">
            <description >
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
                <prompt name="&apos;Type Month Number&apos;" description="&apos;Type Month Number&apos;" row="0" col="0" len="02" default="" clearfield="false" encrypted="false" movecursor="true" xlatehostkeys="true" assigntovar="$Month$" varupdateonly="true" required="false" title="&apos;Type Month Number&apos;" />
         </actions>
            <nextscreens timeout="0" >
                <nextscreen name="Screen2" />
            </nextscreens>
            <recolimit value="10000" />
        </screen>

        <screen name="Screen2" entryscreen="true" exitscreen="false" transient="false">
            <description >
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
                <input value="&apos;6[enter]&apos;" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
            </actions>
            <nextscreens timeout="0" >
                <nextscreen name="Screen3" />
            </nextscreens>
        </screen>

        <screen name="Screen3" entryscreen="false" exitscreen="true" transient="false">
            <description >
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
                <numfields number="55" optional="true" invertmatch="false" />
                <numinputfields number="7" optional="true" invertmatch="false" />
            </description>
            <actions>
                <input value="&apos;[tab]n[tab]n[tab]0[tab]1[tab][tab]&apos;" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
                <input value="$Month$" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
                <input value="&apos;[field+][enter][enter]&apos;" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
            </actions>
            <nextscreens timeout="0" >
            </nextscreens>
        </screen>

    </HAScript>



    ------------------------------
    Greg Cornett
    ------------------------------



  • 9.  RE: HAScript problem

    Posted Fri September 29, 2023 11:35 AM

    I rebuilt the macro from scratch, and gave the month variable a different name.  I think this will work for you:

    <HAScript name="test xxx" description="" timeout="60000" pausetime="300" promptall="true" blockinput="true" author="Steven Lukas" creationdate="Sep 28, 2023" supressclearevents="false" usevars="true" ignorepauseforenhancedtn="true" delayifnotenhancedtn="0" ignorepausetimeforenhancedtn="true" continueontimeout="false">

        <vars>
          <create name="$Month$" type="string" value="" />
        </vars>


        <screen name="Screen1" entryscreen="true" exitscreen="false" transient="false">
            <description >
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
                <prompt name="&apos;Type Month Number&apos;" description="&apos;Type Month Number&apos;" row="0" col="0" len="02" default="" clearfield="false" encrypted="false" movecursor="true" xlatehostkeys="true" assigntovar="$Month$" varupdateonly="true" required="false" title="&apos;Type Month Number&apos;" />
         </actions>
            <nextscreens timeout="0" >
                <nextscreen name="Screen2" />
            </nextscreens>
            <recolimit value="10000" />
        </screen>

        <screen name="Screen2" entryscreen="true" exitscreen="false" transient="false">
            <description >
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
            </description>
            <actions>
                <input value="&apos;6[enter]&apos;" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
            </actions>
            <nextscreens timeout="0" >
                <nextscreen name="Screen3" />
            </nextscreens>
        </screen>

        <screen name="Screen3" entryscreen="false" exitscreen="true" transient="false">
            <description >
                <oia status="NOTINHIBITED" optional="false" invertmatch="false" />
                <numfields number="55" optional="true" invertmatch="false" />
                <numinputfields number="7" optional="true" invertmatch="false" />
            </description>
            <actions>
                <input value="&apos;[tab]n[tab]n[tab]0[tab]1[tab][tab]&apos;" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
                <input value="$Month$" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
                <input value="&apos;[field+][enter][enter]&apos;" row="0" col="0" movecursor="true" xlatehostkeys="true" encrypted="false" />
            </actions>
            <nextscreens timeout="0" >
            </nextscreens>
        </screen>

    </HAScript>



    ------------------------------
    Greg Cornett
    ------------------------------