Chapter Contents

Previous

Next
Run-Time Argument Processing

Standard File Redirection

Redirections allow the choice of the standard input and output files to be made at run-time. Redirections are affected by the _style variable. The _style variable must be an external variable.

The _style variable can have the value of any valid pathname style and determines the default style prefix. For example, assume you have a program containing the following declaration:

char *_style = "tso";

Then, the following TSO program call would request that stdin be opened to tso:input.data(file5) :

call mypgms(simple) '<input.data(file5)'

Refer to the discussion of _style in Program Standard File Specification for additional information.


Alternate CMS Redirection Format

The library under CMS allows two forms of fileid specification in a redirection. The usual specification is of the following form:

simple -x -y <data.file.a >output.listing

The fileid is simply any valid CMS pathname in the no-blanks format. Another example of this form is the following:

simple -x -y <cms:rdr >printer

This form of fileid specification is subject to truncation, however, if only a CMS tokenized parameter list is available to the library. If the C program can be invoked so that only a CMS tokenized parameter list is available to the library, you should use the alternate form of redirection. In this alternate form, the filename, filetype, and filemode are specified as separate tokens and surrounded by parentheses, as in the following:

simple -x -y <(data file a) >(output listing)

or

simple -x -y <(rdr) >(printer)

This form of fileid is not subject to truncation in a tokenized parameter list.


Program Standard File Specification

A program also can specify an input or output redirection for standard C files. Options controlling standard file redirection can be specified in the program source as follows:

char *_stdinm  = string ,
     *_stdonm  = string ,
     *_stdenm  = string ;

char *_stdiamp = string ,
     *_stdoamp = string ,
     *_stdeamp = string ;

The _std xxxx variable must be an external variable. The variables are used as follows:

You can also initialize the character pointer variable _style to address a string that will be used by the run-time system as a style prefix for all I/O open requests that do not specify a style prefix. However, note that _style is ignored for a program compiled with the posix option.

The format for _style is as follows:

char *_style   = string ;

The string should be no longer than four characters (not including the optional final colon and the terminating null). The value specified for _style affects filenames specified on the command line. For example, under CMS if _style is set to ddn: and PRINTER is specified on the command line, output is sent to DDname PRINTER and not to your virtual printer.

Note:    Program option specification is not portable.  [cautionend]

For more information on filenames and styles, and amparms, refer to Chapter 3, "I/O Functions," in SAS/C Library Reference, Volume 1.


Chapter Contents

Previous

Next

Top of Page

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