Please enable JavaScript to view this site.

ESL Documentation

The first code segment is a sample of how you can manage the watch command strings in a text file. Once the command string text file is created, the watch command strings can be retrieved and executed.

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

# These subroutines provide a method for externalizing watch

# criteria.

#

# You create your own watch command strings, give them a name,

# and pass the name and command (with a working textual region

# name) to WriteEcsCommand(), which will append the name of the

# command with the command to the textual region.

#

# After you have completed creating all of your watch criteria

# (and placed them into the textual region via WriteEcsCommand),

# you then write them out to a text file by calling

# WriteEcsCommandFile().  This will write (destructively) the

# textual region out to the file name specified.

#

# You can retrieve the command strings by doing the following:

# - reading the text file into your working textual region

# (ReadEcsCommandFile) by passing the name of the textual

# region and the file name.

#

# - reading the command string ( ReadEcsCommand) by passing the

# name of the textual region and name of the string. Returns

# the command string.

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

 

string DELIMITER is ":"

 

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

# subroutine: WriteEcsCommand

#

# Writes the ECS command string and its name to the textual

# region defined by Watch_TR

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

 

subroutine WriteEcsCommand (string: Watch_TR,   # TR with watch

                                                # commands (read in

                                                # from file)

                            string: Command_SV  # watch command

                                                # string

                                                # (returned valued)

                           ) is

    add to Watch_TR

    move to column 1 line ((bottom of Watch_TR) + 1)

    insert Name_SV DELIMITER Command_SV

 

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

# subroutine: ReadEcsCommand

#

# Reads the ECS command string specified by Name_SV from the

# textual region (defined by Watch_TR) into Command_SV.

# Command_SV returns "" (null) if not found.

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

 

subroutine ReadEcsCommand (string: Watch_TR,    # TR with watch

                                                # commands (read in

                                                # from file)

                           string: Name_SV,     # name of the watch

                           string: Command_SV   # watch command # string # (returned valued)

                            ) is

string  Temp_SV

boolean Found_BV is false

 

    add to Watch_TR

    move to column 1 line 1

 

    while (not Found_BV) loop

        find in Watch_TR Name_SV

        if ( not Found_BV ) then

            send "Watch not found in Watch Command File.\n" to errorlog

        copy "" to Command_SV

        end if

        if (xcursor = 1) then

            copy ( textual line ( ycursor of Watch_TR ) from Watch_TR ) to Temp_SV

            extract from Temp_SV

                skip by DELIMITER               # Name_SV

                take to last Command_SV

        else                                    # since it isn't the first item

            copy false to Found_BV              # on the line, it isn't the

                                                # keyword that we're looking for.

                                                # Keep trying.

        end if

    end loop

 

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

# Subroutine: ReadEcsCommandFile

#

# Reads the ECS command file, defined by WatchFile_SV, into

# textual region, Watch_TR.  If Clear_BV is true, then the

# textual region is cleared first, before the file is read in.

# Otherwise, the file is appended to whatever is already in the

# textual region.

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

 

subroutine ReadEcsCommandFile( string:  WatchFile_SV, # watch command

                                                      # file name string:

                               string:  Watch_TR,     # TR for watch boolean:

                               boolean: Clear_BV      # true, clear # TR

                             ) is

    if (Clear_BV) then

        clear Watch_TR

    else

        add to Watch_TR

        move to column 1 line ((bottom of Watch_TR) + 1)

    end if

 

    read file WatchFile_SV into Watch_TR

    if (ioerror) then

        send "READ ERROR: Cannot read file (" WatchFile_SV ").\n"

          to errorlog end if

 

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

# Subroutine: WriteEcsCommandFile

#

# Writes the textual region, Watch_TR, out to the file,

# WatchFile_SV

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

 

subroutine WriteEcsCommandFile( string: WatchFile_SV,   # watch command

                                                        # file name

                                string: Watch_TR,       # TR for watch

                                boolean:Clear_BV        # true, clear

                                                        # TR

                              ) is

 

write destructive Watch_TR to file WatchFile_SV

if (ioerror) then

    send "WRITE ERROR: Cannot write to file (" WatchFile_SV ").\n"

    to errorlog

end if

 

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