$Command: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 8: Line 8:
The <var>$Command</var> function accepts five arguments and returns a number indicating the success of the function. It is also callable .
The <var>$Command</var> function accepts five arguments and returns a number indicating the success of the function. It is also callable .
==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %rc = $Command(cmd, msgctl, image_name, file, width)
<p class="syntax"><section begin="syntax" />%rc = $Command(cmd, msgctl, image_name, file, width)
<section end="syntax" /></p>
<section end="syntax" /></p>
<p class="caption">$Command Function
<p class="caption">$Command Function

Revision as of 20:32, 24 October 2012

Execute Model 204 command on sdaemon, results to image

Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Command function is Run (Daemon function). The OO APIs emphasize the use of the Daemon methods; users are strongly urged to use the new Daemon API instead of the old $functions.

This function allows a Model 204 command to be executed on an sdaemon with the results returned to an image. $Command performs the same function as $CommndL except that data is returned to an image rather than a $list. $CommndL and $CommBg are recommended over $Command, as they run with less overhead, are simpler to use, and return their output in a $list.

The $Command function accepts five arguments and returns a number indicating the success of the function. It is also callable .

Syntax

<section begin="syntax" />%rc = $Command(cmd, msgctl, image_name, file, width) <section end="syntax" />

$Command Function

%rc is set to 0 or an error code.

cmd A string containing the Model 204 command to be executed. This is a required argument.
msgctl A number indicating the setting to be used for MSGCTL when issuing the command in the sdaemon. This is an optional parameter, and it defaults to the user's current MSGCTL setting.
image_name The name of an image to receive the command output. This image should have the following format:

IMAGE CMD_OUT ARRAY_SIZE IS BINARY LEN 4 DISC_NUM IS BINARY LEN 4 NEXT_OUT IS BINARY LEN 4 LINES_OUT IS BINARY LEN 4 ARRAY OCCURS n OUT_ARRAY IS STRING LEN x END ARRAY END IMAGE

Where:

  • ARRAY_SIZE is the number of entries in OUT_ARRAY.
  • DISC_NUM is the number of output
  • NEXT_OUT is the array item number of the next entry to be set.
  • LINES_OUT is a return parameter and is set to the
  • OUT_ARRAY is a string array that contains the captured data.
  • The value of n, in OCCURS n,
This must be set prior to calling the function. lines to be discarded before capturing starts. number of lines captured. The length, x, should be set to the value of the fifth parameter passed to the function as described below. indicates the number of lines of output expected. The image_name argument is optional. If it is omitted, command output is printed to the output stream of the current user (the user invoking $Command).
file A string indicating the name of a file that is to be automatically opened by the sdaemon and made the current file before cmd is executed. The file is opened with the same access privileges the user currently has for the file. This is an optional parameter.
width A number indicating the line width to be used for output lines. This is an optional argument, and it defaults to 80. Under Sirius Mods Version 6.2 and earlier: if this value is not in the range 1-256, the default is used. Under Sirius Mods Version 6.3 and later: this value can be specified as any value between 1 and the minimum LOBUFF value for any sdaemon thread in the Online, and if the value is not a valid number or not in this range, the request is cancelled.

0 - Command successfully executed 4 - Command processed, errors produced 8 - sdaemon restarted 12 - sdaemon required more input 16 - No sdaemons are running 20 - Out of storage 24 - Specified output image not found 28 - Image not active 32 - Image too short 36 - Image contains invalid data 40 - Invalid file identifier

$Command return codes

The following program issues a VIEW command and displays the result at the user's terminal.

B IMAGE CMD_OUT ARRAY_SIZE IS BINARY LEN 4 DISC_NUM IS BINARY LEN 4 NEXT_OUT IS BINARY LEN 4 LINES_OUT IS BINARY LEN 4 ARRAY OCCURS 10 OUT_ARRAY IS STRING LEN 80 END ARRAY END IMAGE %I IS FIXED DP 0 %RC IS FIXED DP 0 PREPARE IMAGE CMD_OUT %CMD_OUT:ARRAY_SIZE = 10 %RC = $Command('VIEW',,'CMD_OUT') FOR %I FROM 1 TO 10 PRINT %CMD_OUT:OUT_ARRAY(%I) END FOR PRINT '10 lines printed. RC= ' AND %RC END