View Single Post
Old 13 July 2015, 19:00   #55
Registered User

BigFan's Avatar
Join Date: Feb 2014
Location: Germany
Posts: 261
Open your Rexx Port

If you get this far reading here, then you should be able to figure out how to use
Showdir() or Showlist(). No big deal. I save time not to explain basic stuff.

The most intrigueing functions are to control your own rexx port. This is a complex
thing and is best explained with an example code.


/* */

/* */
Options Results

If ADDLIB('rexxsupport.library',0,-30,0)=0 Then Do


  do forever
    if arg=quit then break
    if arg=version then do
      Address command 'requestchoice Title "Version" Body "Catcher V1.0" OK'
Else Do
 Say "rexxsupport.library not found"
We start with a check if the library can be opened successfully.
If not, find exit.

I named the port catch, no quotation marks, we deal with upper case !!
After successfully open a port, the code enters an infinite loop.
Waitpkt() is systemfriendly and sets our rexx program to sleep, waiting for the first
loves first kiss to awaken the beautiful princess (resting in the highest tower
guarded by a dragon). eerrrmm. oops

If our program receives a message we fetch it with Getpkt()
We pick the content (if any) with Getarg() and make it upper case (or we have to
find a way to deal with case-sensetivity).
We check for two commands, QUIT and VERSION. QUIT forces the code to exit. Version
prints a silly version string in a requester.

How to control?

First, run the example from workbench (add an icon, set rx as command)
or use shell command "run" to detach from console.
Now the program stays in background with the default RX output window.

Open a shell, if not already.

Check if our catcher is waiting : rx "say show(p)"
CATCH should be listed as available port

rx "address catch version"
The silly version string shows up in rexx window

rx "address catch quit"
Commands the program to terminate.

All this can be done from inside any other rexx program.

If you want to communicate (CATCH should send results to your programm, f.e.) you
have to add the code for port creation to your newly written program.

The example above lacks error handling. Never forget that almost everything could fail.
Better be save than freezed

Bug fix:
first version checked for success on open library and exits instead of continue

Last edited by BigFan; 14 July 2015 at 13:22. Reason: title added, silly bug found
BigFan is offline  
Page generated in 0.05172 seconds with 11 queries