English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System > Coders. Scripting

 
 
Thread Tools
Old 04 October 2015, 04:48   #1
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,928
Returning strings via ARexx port

I've gone through the hoops of creating an ARexx port in an ARexx program (using rexxsupport.library), and it is able to receive commands from another script that opens its port, but what I can't seem to find out from Commodore's scanty documentation is how to send back a result. I can send a return code, but that's the RC code. What I need is to send the RESULT code.

Was this omitted from rexxsupport.library?
idrougge is offline  
Old 04 October 2015, 10:37   #2
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,877
Code:
if (msg->rm_Result1 == 0)
	if (msg->rm_Action & RXFF_RESULT)
		msg->rm_Result2 = (long) CreateArgstring (result,strlen(result));
thomas is offline  
Old 06 October 2015, 14:47   #3
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,928
No, I mean that I create a port in an ARexx, not from C.
I'm using OpenPort() in rexxsupport.library to create the port, then an event loop using WaitPkt(), GetPkt() and Reply().
idrougge is offline  
Old 06 October 2015, 17:31   #4
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 2,388
I never need/used message ports but I read a bit about so take my answer as it is. You are maybe right that rexxsupport.library doesn`t provide such a function because the docs says that it is limited compared to C functionality. Maybe rmh.library does it better?

Create two ports in each script one seems a bad idea, right?

If you do REPLY(Packet, rv) does it help if you use SETCLIP() and GETCLIP() to send your RESULT back? In that case you need to listen on the reply in some way. Don`t know if that works.

Can/want you post/upload your script?
daxb is offline  
Old 07 October 2015, 04:19   #5
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,928
Quote:
Originally Posted by daxb View Post
Create two ports in each script one seems a bad idea, right?
Why that's ingenious — in a stupid kind of way.

Quote:
Originally Posted by daxb
If you do REPLY(Packet, rv) does it help if you use SETCLIP() and GETCLIP() to send your RESULT back? In that case you need to listen on the reply in some way. Don`t know if that works.
While I've thought of it, it's not aesthetically pleasing.

Quote:
Originally Posted by daxb
Can/want you post/upload your script?
Code:
/* $VER: 1
*/
IF ~Init() THEN SIGNAL Quit
DO FOREVER
   CALL WaitPkt('HASH')
   paket=GetPkt('HASH')
   IF paket>0 THEN DO
      medd=GetArg(paket,0)
      svar=0
      SELECT
         WHEN Left(medd,4)=='HASH' THEN DO
            PARSE VAR medd 'HASH ' filnamn
            svar=MakeChecksum(filnamn)
            END
         WHEN medd='DIE'  THEN DO
            SAY 'Quitting'
            CALL Reply(paket,0)
            EXIT 0
            END
         OTHERWISE SAY 'Unknown command:' medd
         END
      END
   CALL Reply(paket,svar)
   END

EXIT 0

Init:
SELECT
   WHEN  Show('LIBRARIES','rexxsupport.library') THEN NOP
   WHEN ~AddLib('rexxsupport.library',0,-30,0)   THEN EXIT 10
   OTHERWISE EXIT 20
   END
IF Show('PORTS','HASH') THEN EXIT 5
IF ~OpenPort('HASH')    THEN EXIT 5
IF ~Close(stdin)  THEN EXIT 20
IF ~Close(stdout) THEN EXIT 20
IF ~Open(stdout,'CON:////Hashserv/CLOSE/WAIT/AUTO','WRITE') THEN DO
   SAY 'Could not open stdio'
   EXIT 20
   END
RETURN 1

Quit:
   SAY 'Error in line' SIGL
   EXIT 10
idrougge is offline  
Old 07 October 2015, 17:03   #6
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 2,388
I guess you send a message (some kind of string? file name?) to port 'HASH' and it makes a checksum from it? This checksum string you want to send back but it doesn`t work because "Reply(paket,svar)" only support an integer number as result code. It would be interesting to know how the script/command/whatever looks/works you used to send messages to port 'HASH'.

Without that information I would guess at moment that using three different RC values with Reply(paket, rc) what can be send back + fitting SETCLIP() to caller could work. There you should be able to identify/analyse the RC value and get the results via GETCLIP(). However, just an idea. Maybe there are other/better solutions maybe without using ports.
daxb is offline  
Old 08 October 2015, 00:47   #7
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,928
Quote:
Originally Posted by daxb View Post
I guess you send a message (some kind of string? file name?) to port 'HASH' and it makes a checksum from it? This checksum string you want to send back but it doesn`t work because "Reply(paket,svar)" only support an integer number as result code.
Correct.

Quote:
Originally Posted by daxb
It would be interesting to know how the script/command/whatever looks/works you used to send messages to port 'HASH'.
For the moment, it's just a small loop used to evaluate the program:
Code:
/* rexx */
options results
do forever
	parse pull ord
	address 'HASH' ord
	say rc':' result
	end
Quote:
Originally Posted by daxb
Without that information I would guess at moment that using three different RC values with Reply(paket, rc)
What you just wrote there solved my problem! It turns out that Reply() can take three arguments, unlike what's stated in the manual. The full syntax is Reply(packet_id,rc_value,result_value). So now it works! Thanks!
idrougge is offline  
Old 08 October 2015, 16:34   #8
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 2,388
Does that mean when your reply with Reply(packet_id,rc_value,result_value) the RESULT var becomes the result_value you send? Maybe I`m doing something wrong because I only get RESULT = RESULT, not the value sent. I used your evaluation program.
daxb is offline  
Old 08 October 2015, 16:53   #9
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,877
You have to set OPTIONS RESULTS in the calling program.
thomas is offline  
Old 08 October 2015, 18:20   #10
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 2,388
I did that. Further for both scripts.
daxb is offline  
Old 08 October 2015, 23:46   #11
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,928
If you trace the program, you'll find that IF paket>0 THEN DO is never evaluated, because the packet ID is not >0. Change to ~=0.
idrougge is offline  
Old 09 October 2015, 01:55   #12
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 2,388
I used the example from ARexx.guide with small changes what uses:
if Packet ~= null() then do
daxb is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning to Amiga after 25 years ... hedders New to Emulation or Amiga scene 17 08 May 2015 00:00
Concatenating strings? christopherpm Coders. Asm / Hardware 10 10 July 2013 20:43
Another one returning GarethPW Member Introductions 5 06 July 2011 14:14
Strange debugger strings for DFx.... Alexco support.WinUAE 1 27 May 2009 23:21
Returning to Amigas - new to emulation antonvaltaz Member Introductions 9 19 May 2009 13:02

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:25.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.07584 seconds with 15 queries