Please enable JavaScript to view this site.

ESL Documentation

This code segment gives an example of how watch commands can be built ahead of time and be used in a loop to watch for any one of many screens that may appear, including an error condition. The watch commands are placed in an array to simplify the code inside the loop. The sample code given here does not show navigation; therefore, you need to build your own navigation routines.

#

# INCLUDE FILE REFERENCE

#

include "eslcmsrv.inc"                      # ECS declarations file

include "message.inc"

 

integer constant

 MAX_OPTIONS is 5                           # maximum number of screens

 MAX_LOOP is 30

 

integer TimeLimit_IV

        ScreenOption_IV

        ErrorLevel_IV

        EcsErrorLevel is 0

 

string  Message_SV

        Title_SV

        Watch_SV

        GoFromMenuWatch_SV [MAX_OPTIONS]    # an array of watch

                                            # command strings

boolean WatchGaveUp_BV

        NoError        is true

 

 

#----------------------------------------------------------------

# action routines to define all watch command strings

#----------------------------------------------------------------

 

action DefineWatchForScreenA is

    call EcsClearWatch ( Watch_SV )

    copy errorlevel to ErrorLevel_IV

    call ErrorHandler( NoError, EcsErrorLevel )

 

action DefineWatchForErrorCondition is

    call EcsClearWatch ( Watch_SV )

    copy errorlevel to ErrorLevel_IV

    call ErrorHandler( NoError, EcsErrorLevel )

 

#----------------------------------------------------------------

# build watch command strings into the array

#----------------------------------------------------------------

 

action InitGoFromMenuWatches is

    action DefineWatchForScreenA

    copy Watch_SV to GoFromMenuWatch_SV[1]

    #...

 

    action DefineWatchForErrorCondition

    copy Watch_SV to GoFromMenuWatch_SV[5]

 

subroutine WatchForAllScreens( integer: Screen_IV ) is

    integer Count_IV

            LoopCount_IV

 

    copy 0 to Screen_IV     # initialize return value to

                            # something it couldn't possibly BE

    copy 0 to TimeLimit_IV  # set time limit to 0

    copy true to WatchGaveUp_BV

 

#----------------------------------------------------------------

# you will need to add your own navigation here, before you look

# for the screens

#------------------------------------------------------

    for LoopCount_IV = 1 to MAX_LOOP by 1

        loop OuterLoop

            for Count_IV = 1 to MAX_OPTIONS by 1

            loop WatchForScreensLoop

 

            #------------------------------------------------

            # loop through the array of watch command strings

            # looking fo r each screen

            #------------------------------------------------

 

                copy GoFromMenuWatch_SV[ Count_IV] to Watch_SV

                call EcsWatchAndWait ( TimeLimit_IV, Watch_SV )

                copy errorlevel to ErrorLevel_IV

                call ErrorHandler( NoError, EcsErrorLevel )

 

                if ( ErrorLevel_IV != 0) then       # an error was encounterd

                    copy false to WatchGaveUp_BV

                    leave loop OuterLoop

                end if

                copy EcsWaitGaveUp to WatchGaveUp_BV

                if (not WatchGaveUp_BV) then        # watch was sucessful

                    copy Count_IV to Screen_IV      # this is the screen

                                                    # number we found

                    leave loop OuterLoop

                end if

            end loop WatchForScreensLoop

        end loop OuterLoop

 

        if (ErrorLevel_IV != 0) then

             # an error was encountered

             # watch was not successful

        end if

 

response to start

    action InitGoFromMenuWatches        # build the watch command strings ...

 

#----------------------------------------------------------------

# A user action caused the host to retrieve any one of a number

# of screens.

#----------------------------------------------------------------

 

response to GoFromMenu_PB

    copy false to WatchGaveUp_BV

    while ( not WatchGaveUp_BV ) loop

        call WatchForAllScreens( ScreenOption_IV )

        if ( ( ErrorLevel_IV = 0) and WatchGaveUp_BV ) then

            copy "HOST SYNCHRONIZATION" to Title_SV

            copy "Host has not responded. Do you want to retry?" to Message_SV

            if ( ReplyToMessage ( Title_SV, Message_SV, MessageYesNo, 2, MessageWarning ) = "yes" ) then

                copy false to WatchGaveUp_BV

            end if

        end if

    end loop

    if (ScreenOption_IV = 5) then

        # error condition occurred

    end if