I'm planning to make Hollywood programs which would interact with many other programs via their ARexx ports, but I haven't found any functions to check if a port is available yet. It would be needed to check if a program is running, before trying to send ARexx commands randomly to it. Hollywood programs seem to exit with an error message when you send an Arexx command to a non existing port.
With actual ARexx scripts I do that with SHOW('P', 'PORTNAME') and with the Lua implementation in MorphOS with ipc.checkport('portname'), but what could I use with Hollywood?
One workaround could be using the ARexx for that with something like this RunRexxScript("RETURN SHOW('P','JUKEBOX')", True), but it has disadvantages like not working out of the box on MorphOS, because user would need to install 3rd party rexxsyslib.library first, so I'd really prefer a native builtin solution in Hollywood. Is there some obvious function or would this post be better in feature requests?
Edit: actually SendRexxCommand() function seems to require the working ARexx implementation (rexxsyslib.library) too, so it won't work directly under plain MorphOS either. I first thought these would work like the Lua implementation or RXCmd in MorphOS which bypasses the ARexx itself when just sending commands to ARexx ports (when not running any scripts, just send the command and receive the result). Well, this functionality definitely would be a feature request next
Maybe some kind of WaitForPort function could be handy too if you need to wait for a launched program to appear? Like ipc.waitforport(name[, interval]) in MorphOS's Lua implementation.
Checking ARexx port availability
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Checking ARexx port availability
Just disable automatic error handling using ExitOnError() for the time being and then use GetLastError() to check if an error occurred.jPV wrote:I'm planning to make Hollywood programs which would interact with many other programs via their ARexx ports, but I haven't found any functions to check if a port is available yet. It would be needed to check if a program is running, before trying to send ARexx commands randomly to it. Hollywood programs seem to exit with an error message when you send an Arexx command to a non existing port.
With actual ARexx scripts I do that with SHOW('P', 'PORTNAME') and with the Lua implementation in MorphOS with ipc.checkport('portname'), but what could I use with Hollywood?
Actually, I don't really know much about Rexx and I haven't touched Hollywood's ARexx code for 10 years or so, hence I think it would be better if the MorphOS guys came up with a native rexxsyslib implementation or just drop in the OS3 library. Any serious stuff with Rexx will require the lib anyway...One workaround could be using the ARexx for that with something like this RunRexxScript("RETURN SHOW('P','JUKEBOX')", True), but it has disadvantages like not working out of the box on MorphOS, because user would need to install 3rd party rexxsyslib.library first, so I'd really prefer a native builtin solution in Hollywood. Is there some obvious function or would this post be better in feature requests?
Edit: actually SendRexxCommand() function seems to require the working ARexx implementation (rexxsyslib.library) too, so it won't work directly under plain MorphOS either. I first thought these would work like the Lua implementation or RXCmd in MorphOS which bypasses the ARexx itself when just sending commands to ARexx ports (when not running any scripts, just send the command and receive the result). Well, this functionality definitely would be a feature request next
Maybe some kind of WaitForPort function could be handy too if you need to wait for a launched program to appear? Like ipc.waitforport(name[, interval]) in MorphOS's Lua implementation.
Re: Checking ARexx port availability
In any case it would be better if there would be a dedicated function to check the ports. It would be a clean solution to check which other programs are available if you have several options to interact with, and it's a good practise to check availability before sending lots of ARexx commands somewhere and then wonder the results. But I guess I can live with that RunRexxScript workaround...airsoftsoftwair wrote:Just disable automatic error handling using ExitOnError() for the time being and then use GetLastError() to check if an error occurred.jPV wrote:I'm planning to make Hollywood programs which would interact with many other programs via their ARexx ports, but I haven't found any functions to check if a port is available yet. It would be needed to check if a program is running, before trying to send ARexx commands randomly to it. Hollywood programs seem to exit with an error message when you send an Arexx command to a non existing port.
With actual ARexx scripts I do that with SHOW('P', 'PORTNAME') and with the Lua implementation in MorphOS with ipc.checkport('portname'), but what could I use with Hollywood?
No, I planned to do the serious stuff with Hollywood and just utilize the ports/commands on other programs Just like I do with Lua... I like to keep with one language at time and there's no need to mess more with the actual ARexx language if you just want to utilize what some programs offer through the port.Any serious stuff with Rexx will require the lib anyway...
Another issue which came up with ARexx now is the SendRexxCommand() funtcion. The documentation tells like this:
But I can't get the result like that no matter which programs I try it with and it looks that it never return the results of the sent commands.res$ = SendRexxCommand(port$, cmd$)
This function sends the command specified in cmd$ to the Rexx port specified in port$. The function will then return the result from the command. The return value will always be a string - even if it contains just a number.
I found a workaround to that by injecting couple of other ARexx commands with the actual command, but it kind of kills the elegancy of the SendRexxCommand...
Here's an example of both cases:
Code: Select all
DebugPrint("Test1: "..SendRexxCommand("AMIRC.1", "GETMYNICK"))
DebugPrint("Test2: "..SendRexxCommand("OWB.1", "GETURL"))
DebugPrint("Test3: "..SendRexxCommand("AMIRC.1", "OPTIONS RESULTS;GETMYNICK;RETURN RESULT"))
DebugPrint("Test4: "..SendRexxCommand("OWB.1", "OPTIONS RESULTS;GETURL;RETURN RESULT"))
End
Test1:
Test2:
Test3: jPV
Test4: http://www.hollywood-mal.com/help.html
So, it doesn't work like written in the manual...
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Checking ARexx port availability
The problem is that you are in a multitasking environment so even if there was a function like PortExists() it would still be unreliable because the port can go away at any time. So PortExists() could return TRUE and SendRexxCommand() could still fail because the program has been closed in the meantime. Well, I'll think about it ... maybe I'll add such a function for a future version. Wouldn't be much of a problem but it will always be unreliable because of the multitasking environment.jPV wrote: In any case it would be better if there would be a dedicated function to check the ports. It would be a clean solution to check which other programs are available if you have several options to interact with, and it's a good practise to check availability before sending lots of ARexx commands somewhere and then wonder the results. But I guess I can live with that RunRexxScript workaround...
But 99% of the people have rexxsyslib.library anyway on MorphOSNo, I planned to do the serious stuff with Hollywood and just utilize the ports/commands on other programs Just like I do with Lua... I like to keep with one language at time and there's no need to mess more with the actual ARexx language if you just want to utilize what some programs offer through the port.
Right, I can confirm this behaviour. But I'm not sure whether this is a bug or a feature because all my knowledge of ARexx has pretty much vanished. I never was an ARexx guy. I just read up on it when I wrote the Hollywood ARexx library which must have been in 2006 or so. But since then I've almost forgotten everything about Rexx The only thing I remember was that the implementation had to be done quite carefully and that the whole thing was quite fragile and not everything was documented so I'm very reluctant to touch anything here unless it's proven to be a bug...But I can't get the result like that no matter which programs I try it with and it looks that it never return the results of the sent commands.
I found a workaround to that by injecting couple of other ARexx commands with the actual command, but it kind of kills the elegancy of the SendRexxCommand...
So, it doesn't work like written in the manual...
Looking at your code I could of course extend SendRexxCommand() to always extend the command in the way you did. So if your script does
Code: Select all
SendRexxCommand("XXX", "CMD")
Code: Select all
SendRexxCommand("XXX", "OPTIONS RESULTS;CMD;RETURN RESULT")