Chapter Contents

Previous

Next
cmsstack

cmsstack



Insert a String into the CMS Program Stack

Portability: SAS/C extension


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
USAGE NOTES
EXAMPLE


SYNOPSIS

#include <cmsexec.h>

int cmsstack(int order, const char *str, int len);


DESCRIPTION

cmsstack inserts the character array addressed by str of length len onto the CMS program stack in either last-in-first-out (LIFO) or first-in-first-out (FIFO) order depending on the value of the order argument. ( cmsstack can be used in any CMS application, not just with function packages.)

<cmsexec.h> defines two values for order : STK_LIFO and STK_FIFO. If len is 0 , then the character array addressed by str is assumed to be null-terminated.


RETURN VALUE

cmsstack returns 0 if the string was inserted or a nonzero value if the string was not inserted.


CAUTION

The maximum value of len (or if len is 0 the maximum length of the string addressed by str ) is 255.


USAGE NOTES

<cmsexec.h> also defines two macros based on cmsstack . The definitions are shown here, followed by an example:

   /* cmspush */
#define cmspush(s) cmsstack(STK_LIFO, s, 0)

rc = cmspush("This string is stacked LIFO");

   /* cmsqueue */
#define cmsqueue(s) cmsstack(STK_FIFO, s, 0)

rc = cmsqueue("This string is stacked FIFO");


EXAMPLE

#include <cmsexec.h>

   /* Stack the parameter on the program stack in FIFO order.         */
int main(int argc, char *argv[])
{
   int rc;
   if (argc != 2)
      exit(8);
   rc = cmsstack(STK_FIFO,argv[1],0);
   exit(rc == 0 ? 0 : 8);
}


Chapter Contents

Previous

Next

Top of Page

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