• 3 replies
  • Latest Post - ‏2013-04-05T20:08:10Z by george.baker
1192 Posts

Pinned topic When is a recolimit's value=$n$ evaluated?

‏2011-08-07T14:24:27Z |
With recolimit value="$n$", is n evaluated dynamically each time the screen is recognized, or just once when the macro is started?
Updated on 2013-04-05T20:08:10Z at 2013-04-05T20:08:10Z by george.baker
  • tmparker
    534 Posts

    Re: When is a recolimit's value=$n$ evaluated?

    Hi Eli,

    I have never tried to use recolimit in a dynamic way so I am not sure what would happen. The code for that does not belong to HATS, it is part of the HOD runtime that HATS calls into. There are some situations where HOD will only read a value once and store it but I am not sure if recolimit is one of them. The only real way to know would be to do some tests to see what happens. Set it to a value like 4 an then after the third time recognized change it to a larger value like 10 and see if the macro stops after the fourth time it recognizes that screen. If it keeps running up to the tenth iteration then you know the value can be set dynamically.

  • george.baker
    344 Posts

    Re: When is a recolimit's value=$n$ evaluated?

    I reread the documentation and did some basic testing. First there is a key sentence in the documentation: If the macro runtime recognizes the macro screen this many times, then the macro runtime does not process the actions of this macro screen but instead performs the specified action.

    My first test was to create a macro consisting of three screens. Defined two macro variables
    1. $n$ as integer
    2. $i$ is integer with initial value of 0

    1. GetLoopCount - Entry screen
    1.1. Prompt for loop count and store into $n$
    1.2. Next Screen SignOnLoop

    2. Screen SignOnLoop
    2.1. Update variable, $i$=$i$+1
    2.2. Input $i$ into the User input field
    2.3. Pause for 1 second so you can watch it work
    2.4. Next screen = SignOnLoop
    2.5. <recolimit value="$n$" goto="SignOnExit"/>

    3. SignOnExit - Exit screen
    3.1. Input TheEnd into the User field

    Run the macro and provide loop counts:
    1. A value of zero (0) will loop the macro endlessly on the SignOnLoop screen
    2. A value of one (1) will result in only the SignOnExit screen actions being executed
    3. Entering a value of 5 will result in the SignOnLoop actions being executed 4 times.

    Message: use a value one greater than the number of times you want to execute the actions on the screen.

    Next test is to reset the value of $n$ to watch what happens when the macro runs.
    1. Add a variableupdate to the end of SignOnLoop, $i$=0.
    2. Rerun the macro and specify any value > 0.
    Results is that the macro will loop endlessly.

    Conclusion: The value is evaluated upon every entry to the macro.

    Untested scenario:
    Create at larger loop that involves multiple screens in the loop. I believe that things will behave differently. My suspicion is that <recolimit> works great as long as you loop on a single screen, but once you proceed to a new screen and come back the loop count will be reset. I plan to develop a test for this scenario and update this post with the results. The key will be keeping the macro as simple as possible.
  • george.baker
    344 Posts

    Re: When is a recolimit's value=$n$ evaluated?

    I created another test.
    • prompt for loop one count
    • logon to
    • MainMenu - run boats application
    • Query - select A type and press Enter
    • Next screen is Results
    • Results: page down
    • Next screen #1 is Results page
    • Next screen #2 is ResultsEnd - press PF3
    • Next screen from ResultsEnd is Main Menu

    <recolimit> is applied to:
    • MainMenu = $n$ from the prompt (this works perfectly)
    • Results was set arbitrarily to 3. This is important

    When doing a query for all boats there is a total of 3 pages. The macro logic loops back onto the Results page if BOTTOM is not on the screen. This happens 2 times. The next screen will be ResultsEnd. Thus the recolimit will not ever be reached for this screen. If the recolimit count is not reset at some point, the second time the macro came to the Results page it would take the goto exit, which it did not.

    Result everything works properly, both the inner and outer loop.

    I cannot explain where or why the inner loop count is being reset.