$Command: Difference between revisions
m (1 revision) |
mNo edit summary |
||
Line 2: | Line 2: | ||
<span class="pageSubtitle"><section begin="desc" />Execute Model 204 command on sdaemon, results to image<section end="desc" /></span> | <span class="pageSubtitle"><section begin="desc" />Execute Model 204 command on sdaemon, results to image<section end="desc" /></span> | ||
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Command function is [[ | <p class="warning">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 [[List of Daemon methods|Daemon methods]]; users are strongly urged to use the new Daemon API instead of the old $functions.</p> | ||
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 $ | 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 . | The $Command function accepts five arguments and returns a number indicating the success of the function. It is also callable . | ||
Line 22: | Line 22: | ||
<p class="code"> </p> | <p class="code"> </p> | ||
<ul> | <ul> | ||
Line 44: | Line 42: | ||
<td>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. | <td>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. | ||
</td></tr></table> | </td></tr></table> | ||
<p class="code"> | <p class="code"> | ||
0 - Command successfully executed | |||
4 - Command processed, errors produced | |||
8 - sdaemon restarted | |||
12 - sdaemon required more input | 12 - sdaemon required more input | ||
16 - No sdaemons are running | 16 - No sdaemons are running | ||
Line 59: | Line 58: | ||
<p class="caption">$Command return codes | <p class="caption">$Command return codes | ||
</p> | </p> | ||
The following program issues a VIEW command and displays the result at the user's terminal. | The following program issues a VIEW command and displays the result at the user's terminal. | ||
Line 90: | Line 87: | ||
</p> | </p> | ||
<p class="code"> | <p class="code"> | ||
[[Category:$Functions|$Command]] | [[Category:$Functions|$Command]] |
Revision as of 20:05, 31 January 2011
<section begin="desc" />Execute Model 204 command on sdaemon, results to image<section end="desc" />
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" />
- 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,
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: 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
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