Please enable JavaScript to view this site.

ESL Documentation

After your ESL program has sent the user entries to the host, it may detect an error condition. (In this case, the error condition is detected through one of the watch commands, in which the watch criteria is checking the location of the host.) The subroutine ValidateHost loops through each member of the Validate_CL class (class of all dialog objects that require host validation for the current dialog box or region) and looks for a visual clue that an error has occurred (in this case, an intensified field). If your host application displays an error message on a status line, you may want to retrieve the error message and present it to the user.

#

# INCLUDE FILE REFERENCE

#

include "eslcmsrv.inc"                      # ECS declarations file

include "message.inc"                       # Include message box

                                            # subroutines

 

integer constant ERR_HOST is 1

                ERR_COLOR is CLR_RED

 

integer ErrorLevel_IV

        EcsErrorLevel

 

boolean Continue_BV

        NoError        is true

        ValidateOk_BV

 

class Validate_CL

 

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

# changes the background color of the dialog object to signify

# error.

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

 

subroutine SetErrObject( string : Object_SV, integer: ErrCode_IV) is

    if (ErrCode_IV = ERR_HOST) then

        make Object_SV background color ERR_COLOR

    end if

 

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

# resets the background color of the dialog object to default

# background color.

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

 

subroutine ClearErrObject (string : Object_SV ) is

    make Object_SV background color 26

 

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

#   checks each of the fields (through  Validate_CL class members'

#   parameters) against the host to see if an error has occurred.

#   For example, the parameter value for an entry field may be

#   parameter is "HOST:12,25"

#   the associated entry field location would be at row 12, column 25.

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

 

subroutine ValidateHOST (string : Message_SV ) is

    string  ObjectName_SV

            Parameter_SV

            Temp_SV

 

    integer Row_IV

            Column_IV

            FieldNum_IV

            FieldAttr_IV        is ECS_INTENSIFIED

            FieldAttrState_IV

            ErrCode_IV          is ERR_HOST

 

    copy true to ValidateOk_BV

        for each member of Validate_CL loop

            copy ObjectName_SV to Parameter_SV

 

            extract from Parameter_SV

                skip by "HOST:"

 

            if (marker > 1) then

                extract from Parameter_SV

                skip to marker

                take by number Row_IV

                skip ","

                take by number Column_IV

                call EcsGetFieldNumber( Row_IV, Column_IV, FieldNum_IV )

                copy errorlevel to ErrorLevel_IV

                call ErrorHandler( NoError, EcsErrorLevel )

                if (( ErrorLevel_IV = 0) and ( FieldNum_IV > 0)) then

 

                call EcsGetFieldAttribute ( FieldNum_IV, FieldAttr_IV, FieldAttrState_IV)

                copy errorlevel to ErrorLevel_IV

                call ErrorHandler( NoError, EcsErrorLevel )

                if ( FieldAttrState_IV = ECS_IS_INTENSIFIED) then

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

                     # an error in the entry field has been

                     # encountered.

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

                    copy false to ValidateOk_BV call SetErrObject ( ObjectName_SV, ErrCode_IV )

                else

                    call ClearErrObject ( ObjectName_SV )

                end if

            end if

        end if

    end loop

 

    if ( not ValidateOk_BV ) then

        copy "Invalid data entered in the indicated fields;" Message_SV to Message_SV

        copy ReplyToMessage ( "VALIDATION ERROR: Invalid Data!",

                                Message_SV, MessageOK, 1,

                                MessageWarning )

          to Temp_SV

    end if