2 * This is an example of how to use the SimpleRexx code.
5 #include <exec/types.h>
6 #include <libraries/dos.h>
7 #include <libraries/dosextens.h>
8 #include <intuition/intuition.h>
9 #include <intuition/iobsolete.h>
11 #include <proto/exec.h>
12 #include <proto/intuition.h>
14 #include <rexx/storage.h>
15 #include <rexx/rxslib.h>
20 #include "SimpleRexx.h"
24 * Lattice control-c stop...
26 int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
27 int chkabort(void) { return(0); } /* really */
30 * The strings in this program
34 "50: Window already open", /* STR_ID_WINDOW_OPEN */
35 "101: Window did not open", /* STR_ID_WINDOW_ERROR */
36 "50: No Window", /* STR_ID_WINDOW_NONE */
37 "80: Argument error to WINDOW command", /* STR_ID_WINDOW_ARG */
38 "100: Unknown command", /* STR_ID_COMMAND_ERROR */
39 "ARexx port name: %s\n", /* STR_ID_PORT_NAME */
40 "No ARexx on this system.\n", /* STR_ID_NO_AREXX */
41 "SimpleRexxExample Window" /* STR_ID_WINDOW_TITLE */
44 #define STR_ID_WINDOW_OPEN 0
45 #define STR_ID_WINDOW_ERROR 1
46 #define STR_ID_WINDOW_NONE 2
47 #define STR_ID_WINDOW_ARG 3
48 #define STR_ID_COMMAND_ERROR 4
49 #define STR_ID_PORT_NAME 5
50 #define STR_ID_NO_AREXX 6
51 #define STR_ID_WINDOW_TITLE 7
54 * NewWindow structure...
56 static struct NewWindow nw
=
60 WINDOWSIZING
|WINDOWDRAG
|WINDOWDEPTH
|WINDOWCLOSE
|SIMPLE_REFRESH
|NOCAREREFRESH
,
63 NULL
,NULL
,290,40,-1,-1,WBENCHSCREEN
67 * A *VERY* simple and simple-minded example of using the SimpleRexx.c code.
69 * This program, when run, will print out the name of the ARexx port it
70 * opens. Use that port to tell it to SHOW the window. You can also
71 * use the ARexx port to HIDE the window, to READTITLE the window's
72 * titlebar, and QUIT the program. You can also quit the program by
73 * pressing the close gadget in the window while the window is up.
75 * Note: You will want to RUN this program or have another shell available such
76 * that you can still have access to ARexx...
78 int main(int argc
,char *argv
[])
81 AREXXCONTEXT RexxStuff
;
82 struct Window
*win
=NULL
;
85 if ((IntuitionBase
=(struct IntuitionBase
*)
86 OpenLibrary("intuition.library",0)))
89 * Note that SimpleRexx is set up such that you do not
90 * need to check for an error to initialize your REXX port
91 * This is so your application could run without REXX...
93 RexxStuff
=InitARexx("Example","test");
97 if (RexxStuff
) printf(strings
[STR_ID_PORT_NAME
],
98 ARexxName(RexxStuff
));
99 else printf(strings
[STR_ID_NO_AREXX
]);
104 signals
=ARexxSignal(RexxStuff
);
105 if (win
) signals
|=(1L << (win
->UserPort
->mp_SigBit
));
109 struct RexxMsg
*rmsg
;
110 struct IntuiMessage
*msg
;
112 signals
=Wait(signals
);
115 * Process the ARexx messages...
117 while ((rmsg
=GetARexxMsg(RexxStuff
)))
125 nextchar
=stptok(ARG0(rmsg
),
127 if (nextchar
&& *nextchar
) nextchar
++;
129 if (!stricmp("WINDOW",cBuf
))
131 if (!stricmp("OPEN",nextchar
))
135 error
=strings
[STR_ID_WINDOW_OPEN
];
140 nw
.Title
=strings
[STR_ID_WINDOW_TITLE
];
141 if (!(win
=OpenWindow(&nw
)))
143 error
=strings
[STR_ID_WINDOW_ERROR
];
148 else if (!stricmp("CLOSE",nextchar
))
157 error
=strings
[STR_ID_WINDOW_NONE
];
163 error
=strings
[STR_ID_WINDOW_ARG
];
167 else if (!stricmp("READTITLE",cBuf
))
175 error
=strings
[STR_ID_WINDOW_NONE
];
179 else if (!stricmp("QUIT",cBuf
))
185 error
=strings
[STR_ID_COMMAND_ERROR
];
191 SetARexxLastError(RexxStuff
,rmsg
,error
);
193 ReplyARexxMsg(RexxStuff
,rmsg
,result
,errlevel
);
197 * If we have a window, process those messages
199 if (win
) while ((msg
=(struct IntuiMessage
*)
200 GetMsg(win
->UserPort
)))
202 if (msg
->Class
==CLOSEWINDOW
)
205 * Quit if the close gadget...
209 ReplyMsg((struct Message
*)msg
);
214 if (win
) CloseWindow(win
);
216 FreeARexx(RexxStuff
);
217 CloseLibrary((struct Library
*)IntuitionBase
);