Rexx

From Amiga Development Wiki
Jump to: navigation, search

Sending Rexx message

#include <string.h>
 
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/rexxsyslib.h>
 
int main()
{
   struct MsgPort *rexxport = CreateMsgPort();
 
   if (rexxport)
   {
      struct RexxMsg *rexxmsg = CreateRexxMsg(rexxport, NULL, NULL);
 
      if (rexxmsg)
      {
         rexxmsg->rm_Args[0] = "WINDOW 'Sys:' OPEN";
         rexxmsg->rm_Action = RXCOMM | RXFF_RESULT;
 
         if (FillRexxMsg(rexxmsg, 1, 0))
         {
            struct MsgPort *port;
 
            Forbid();
            port = FindPort("WORKBENCH");
 
            if (port)
               PutMsg(port, &rexxmsg->rm_Node);
 
            Permit();
 
            if (port)
            {
               WaitPort(rexxport);
               GetMsg(rexxport);
            }
         }
 
         ClearRexxMsg(rmsg, 16);
         DeleteRexxMsg (rexxmsg);
      }
 
      DeleteMsgPort(rexxport);
   }
 
   return 0;
}