Chapter Contents |
Previous |
Next |
cmsshv |
Portability: | SAS/C extension |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
IMPLEMENTATION | |
USAGE NOTES | |
EXAMPLE |
SYNOPSIS |
#include <cmsexec.h> int cmsshv(int code, char *vn, int vnl, char *vb, int vbl, int *vl);
DESCRIPTION |
cmsshv
can be called in any situation where REXX or EXEC2 is used,
as well as in conjunction with function packages.
cmsshv
performs the following tasks:
char
The value of
code
determines what action is
performed by
cmsshv
and how the remaining parameters are used.
<cmsexec.h>
defines the following values that
may be used as the value of
code
:
SHV_SET_DIRECT
vn
, must be uppercase. If the name is a REXX stem, the characters following
the period can be in mixed case.
SHV_SET_SYM
code
.
SHV_FETCH_DIRECT
vb
. The variable
name must be uppercase. If the name is a REXX stem, the characters following
the period can be in mixed case.
SHV_FETCH_SYM
code
.
SHV_FETCH_PRIV
ARG
, which fetches the argument string that is parsed by the REXX statement
PARSE ARG
SOURCE
, which fetches the source string that is parsed by the REXX statement
PARSE SOURCE
VERSION
, which fetches the version string that is parsed by the REXX statement
PARSE VERSION.
SHV_FETCH_NEXT
cmsshv
with any other value for
code
.
SHV_DROP_DIRECT
SHV_DROP_SYM
SHV_DROP_DIRECT
except that the name can be in
mixed case.
The values of the remaining arguments
vn
,
vnl
,
vb
,
vbl
, and
vl
are controlled by
code
. The values of these arguments are summarized in the
following table.
RETURN VALUE |
cmsshv
returns a negative value if the operation could not be performed
and a nonnegative value if it was performed.
<cmsexec.h>
defines the negative return values from
cmsshv
as follows:
cmsshv
failed to create a correct EXECCOMM parameter list.
Nonnegative return values from
cmsshv
are any one or
more of the following.
When one or more of these conditions are true, they are logically OR'd to
indicate that the condition occurred.
vb
was too short to contain the entire value of the variable. If
vl
addresses an
int
, the actual length of the value is stored in
*vl
. For SHV_FETCH_NEXT, this value can be returned
if the buffer addressed by
vn
is too short to contain the entire name.
code
is SHV_FETCH_DIRECT and EXEC2 is active.
code
is not one of the values defined in
<cmsexec.h>
.
IMPLEMENTATION |
cmsshv
uses the direct interface to REXX and EXEC2 variables (known
as EXECCOMM) as documented in VM/SP System Product Interpreter Reference, IBM publication No. SC24-5239. Refer to this publication for a
detailed explanation about this interface.
USAGE NOTES |
<cmsexec.h>
also defines three macros for use with
cmsshv
. The macros
execset
,
execfetch
,
and
execdrop
assign, retrieve,
and drop REXX variables, respectively. Using these macros can, in some situations,
simplify the use of
cmsshv
considerably. Each macro is shown here, followed by an example.
/* macro */ execset(char *vn, char *vb); rc = execset("REXXVAR","THIS_VALUE"); /* macro */ execfetch(char *vn, char *vb, int vbl); char valbuf[50]; rc=execfetch("RVAR",valbuf,sizeof(valbuf)); /* macro */ execdrop(char *vn); rc = execdrop("REXXVAR");
EXAMPLE |
#include <cmsexec.h> #include <lcio.h> #include <stdio.h> main() { int rc; int len; char namebuf[20]; char valbuf[200]; rc = cmsshv(SHV_FETCH_NEXT,namebuf,20,valbuf,200,& len); while (rc >= && !(rc & SHVLVAR)) { if (rc SHVTRUNC) { puts("Either name or value truncated."); printf("Actual value length is %d\n",len); } printf("The variable name is: %s\n",namebuf); printf("The variable value is: %.*s\n",len,valbuf); rc=cmsshv(SHV_FETCH_NEXT,namebuf,20,valbuf,200,& len); } }
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.