home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
164.lha
/
ARexx
/
VariableInterface
/
VarTestC.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-04-28
|
2KB
|
60 lines
/* A test program to demonstrate the direct variable interface to ARexx.
* Opens a public port called "VarTest" and then waits for REXX messages.
* The port stays open until a "CLOSE" command is received.
* Usage: run vartest
* Then send commands from within ARexx by "address 'VarTest' command"
*/
#include "exec/types.h"
#include "rexx/storage.h"
#include "rexx/rxslib.h"
#include <stdio.h>
#define VALUE "A-OK"
struct RexxLib *RexxSysBase;
extern LONG CheckRexxMsg(struct RexxMsg *);
extern LONG GetRexxMsg(struct RexxMsg *,STRPTR,STRPTR *);
extern LONG SetRexxMsg(struct RexxMsg *,STRPTR,STRPTR,LONG);
main(argc,argv)
int argc;
char **argv;
{
struct MsgPort MyPort;
struct RexxMsg *rmptr;
LONG test,error;
STRPTR value;
RexxSysBase = OpenLibrary("rexxsyslib.library",(LONG) RXSVERS);
if (RexxSysBase == 0) {
printf("Bad News -- no REXX library\n");
return(20L);
}
/* Initialize our message port */
InitPort(&MyPort,"VarTest");
/* Make the port public */
AddPort(&MyPort);
for (;;) { /* wait for messages */
Wait(1L<<MyPort.mp_SigBit);
rmptr = (struct RexxMsg *) GetMsg(&MyPort);
/* Show what we got */
printf("VarTest: received command %s\n",rmptr->rm_Args[0]);
/* Make sure it's a valid context */
if (CheckRexxMsg(rmptr)) {
printf("VarTest: valid REXX context\n");
if ((error = GetRexxVar(rmptr,"A.1",&value)) == 0)
printf("VarTest: value of A.1 is %s\n",value);
else printf("VarTest: error from get %ld\n",error);
error = SetRexxVar(rmptr,"STATUS",VALUE,strlen(VALUE));
if (error != 0) printf("VarTest: error from 7