Chapter Contents

Previous

Next
Executing C Programs

Executing C Programs under CMS

There are many ways to invoke a C program under CMS. The most frequently used method is to create a MODULE file with the GENMOD command and then invoke the program as any other CMS command. The following example shows how a MODULE file named CMSEXAM can be invoked:

CMSEXAM =w <input.file -z

In the example, the library option =w suppresses the quiet function. <input.file redirects stdin from the file INPUT FILE. -z is a program argument that is to be passed to the main function via the argv vector. See Run-Time Argument Processing for information about the types of program parameters.

C programs in TEXT files can be invoked with the LOAD and START commands, as follows:

LOAD CMSEXAM
START * =w <input.file -z

The program parameters follow the asterisk ( * ) in the START command.

When you execute any C program under CMS, the transient run-time library must be on an accessed disk or in a segment available to your virtual machine. Your installation probably makes it available automatically; if not, ask your SAS Software Representative for C compiler products about how to get access to the transient library.


Using the Debugger

Before using the SAS/C Debugger, it is recommended that you compile with the debug option. Debugger access to program source and variables is permitted only if the C program was compiled with debug . Note that if you compile with dbhook rather than with debug , debugging is limited to commands that do not involve source or variable access. If you compile without specifying either debug or dbhook , use of the debugger is limited to tracing or stopping execution at subroutine call and return. For information on running the debugger under CMS, refer to the SAS/C Debugger User's Guide and Reference.


CMS Parameter Lists

As with any C program, the program parameters are transferred to the main function via the argv vector. C programs under CMS generally use the untokenized parameter list to create the argv vector. (See Run-Time Argument Processing for more information on the argv vector.) The untokenized parameter list does not alter the program parameters, in case or in length. For example:

cmsexam three very-long parameters

In this invocation of a C program, the main function receives pointers to these strings:

three
very-long
parameters

In some cases, however, CMS provides only a tokenized parameter list. If this occurs, the C program parameters are converted to uppercase, and each token is truncated to eight characters. Given the command line above, provided as a tokenized parameter list, the main function receives pointers to the following strings:

THREE
VERY-LON
PARAMETE

Programs that can be invoked by CMS in such a way should be prepared to accept tokenized parameters. Note that C programs invoked via the CMS EXEC processor (as opposed to the EXEC2 processor or REXX) receive tokenized parameters.

Standard file redirections

Under CMS, the standard files stdin and stdout can be redirected to nonterminal files. (See Run-Time Argument Processing for more information.) A typical redirection of stdin from a disk file might look like the following:

cmsexam <data.file.b

If only the tokenized parameter list is available, the redirection parameter is truncated to <DATA.FI, which probably causes an error to occur when stdin is opened. Therefore, the library accepts the following alternate redirection form:

cmsexam <(data file b)

The fileid does not use periods and is entirely enclosed by parentheses. Using this form of redirection parameter does not cause truncation of the fileid in a tokenized parameter list.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.