Slide 47 of 80
Notes:
COMMAND is a user-callable system level API that executes the command passed in as the cmdimage argument. Cmdimage can name any built-in MPE command including the XEQ command, which directly executes scripts and program files. Cmdimage cannot name a UDC or imply a script or program filename. Cmdimage must be terminated with an ASCII carriage return (#13) and cannot exceed 512 bytes, including the CR.
It is recommended to call the COMMAND intrinsic to obtain a system service, such as creating a file, etc. Other intrinsics may provide the same function, yet it is sometimes easier to call COMMAND since the programmer is likely familiar with the interactive CI command that provides the desired service. COMMAND is recommend over HPCICOMMAND in this case since the cmdimage passed to COMMAND cannot be intercepted by a UDC. For example, to create a new file one could call COMMAND passing the string: “build filename”. The built-in MPE BUILD command will be executed, even if there exists a UDC named “BUILD” -- which may do anything, and may not actually create the file at all.
The error argument returns zero, or a CI error number in case of a command execution error. This is the same error number reported if cmdimage is executed interactively, and is the value of the predefined CIERROR JCW/variable. If cmdimage executes with an error or warning there is no indication of this fact, other than the error return value. Specifically, there is no error message reported to $STDLIST, and the CIERROR and HPCIERR CI variables are not modified. In fact COMMAND operates by locally setting the HPMSGFENCE variable to 2, thus suppressing all CI error and warning messages. This is verifiable by executing SHOWVAR programmatically via the EDITOR, e.g.:
:showvar hpmsgfence (= 0) :editor /:showvar hpmsgfence (= 2) Note: a leading “:” causes editor to call COMMAND with the string following the “:”. This is common for many programs.