English Amiga Board


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

 
 
Thread Tools
Old 04 October 2015, 03:48   #1
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
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, 09:37   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
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, 13:47   #3
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
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, 16:31   #4
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
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, 03:19   #5
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
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, 16:03   #6
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
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 07 October 2015, 23:47   #7
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
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, 15:34   #8
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
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, 15:53   #9
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
You have to set OPTIONS RESULTS in the calling program.
thomas is offline  
Old 08 October 2015, 17:20   #10
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
I did that. Further for both scripts.
daxb is offline  
Old 08 October 2015, 22:46   #11
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
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, 00:55   #12
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
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 07 May 2015 23:00
Concatenating strings? christopherpm Coders. Asm / Hardware 10 10 July 2013 19:43
Another one returning GarethPW Member Introductions 5 06 July 2011 13:14
Strange debugger strings for DFx.... Alexco support.WinUAE 1 27 May 2009 22:21
Returning to Amigas - new to emulation antonvaltaz Member Introductions 9 19 May 2009 12: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 13:56.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09085 seconds with 13 queries