English Amiga Board


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

 
 
Thread Tools
Old 09 March 2024, 17:36   #1
Honitos
Registered User
 
Honitos's Avatar
 
Join Date: Nov 2019
Location: Celle / Germany
Posts: 145
Question Problem passing Arexx parameters

Hi guys,


I am struggeling with passing parameters to my program.


I want to send a filename with full path to my program this way:


rx MYPROGRAM OPEN "Ram Disk:file"


where MYPROGRAM is the Arexx-Port of my listening program, OPEN is a command and "Ram Disk:file" is the filename my program should process.


I am checking the incoming Arexx-Message and parse rm_Args[0].


My problem is, the parameter seems to be parsed by the RexxHost or so as I always get this arexxstring:


OPEN Ram Disk:file


without the quotes.



How can I get the parameter string unchanged so that I can parse the parameters correctly?
Honitos is offline  
Old 09 March 2024, 19:40   #2
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,304
I think you cannot use MYPROGRAM as an Arexx-Port.

What about "PARSE ARG cmd filename ." in your script to parse arguments?
daxb is offline  
Old 10 March 2024, 07:04   #3
Honitos
Registered User
 
Honitos's Avatar
 
Join Date: Nov 2019
Location: Celle / Germany
Posts: 145
Cool

Sorry that was an unclear explanation:

MYPROGRAM is just a placeholder, not the real portname, the real portname is "PED.1".
And my program itself is not arexx, but AmiBlitz.

To be concrete, I want to implement an arexxcommand "OPEN" that lead my program to open the file passed to it with the command.
That works well until a path or filename has a space in its name.

And as I want to add additional parameters, I can not concatenate the parameter strings in my program.

Last edited by Honitos; 10 March 2024 at 07:09.
Honitos is offline  
Old 10 March 2024, 09:45   #4
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,001
Quote:
Originally Posted by daxb View Post
I think you cannot use MYPROGRAM as an Arexx-Port.
You can use any name as an ARexx port, why should "MYPROGRAM" be different?


Quote:
Originally Posted by Honitos View Post
My problem is, the parameter seems to be parsed by the RexxHost or so
That's what ARexx does, always and everywhere. If you write ARexx scripts you should be used to it. It resolves variables, changes unknown variables to upper case, executes arithmetic operations and removes quotes.

If you want to keep quotes in strings you have to surround them by quotes, too.

The only difference to a command in a script is that rx does not accept single quotes for the outer surrounding. This makes the command line a bit ugly because to keep double quotes in a string surrounded by double quotes you have to double them...

This one should work:

rx MYPROGRAM OPEN """Ram Disk:file"""

this one looks a bit more readable (well, it would if there was another argument behind the file name):

rx MYPROGRAM "OPEN ""Ram Disk:file"""


In a script you would use single quotes:

Code:
/* rexx */
address MYPROGRAM
'OPEN "Ram Disk:file"'
thomas is offline  
Old 10 March 2024, 17:02   #5
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,304
Sorry, I thought already that I don't have understood the question/problem.

That MYPROGRAM is a placeholder is clear but I didn't knew that you can use "rx <portname> [<arguments>]".
daxb is offline  
Old 11 March 2024, 09:35   #6
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,001
Quote:
Originally Posted by daxb View Post
I didn't knew that you can use "rx <portname> [<arguments>]".
You are certainly right, this is not possible.

Rx either calls a script or executes a command if it begins with a quote.

If you enter

Code:
rx myprogram open "Ram Disk:file"
in a shell, then myprogram.rexx would be called and if myprogram.rexx looks like this:

Code:
/* rexx */
say arg(1)
the output is

Code:
open "Ram Disk:file"
rx does not consume quotes and does not change case.

But the question was about an ARexx port. If you send data to an ARexx port from an ARexx script, then ARexx first processes the command line before it sends it to the port

To do this from rx, you would have to enter

Code:
rx "address myprogram open """"""Ram Disk:file"""""""
or

Code:
rx "address myprogram open '""Ram Disk:file""'"
to keep one set of quotation marks.
thomas is offline  
Old 15 March 2024, 15:16   #7
Honitos
Registered User
 
Honitos's Avatar
 
Join Date: Nov 2019
Location: Celle / Germany
Posts: 145
Thanks for clarification!
Honitos 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
Problem Calling ARexx Command tygre Coders. C/C++ 10 15 March 2023 23:41
Problem executing DOpus5 Arexx Script ... beltrixx support.Apps 1 01 August 2015 22:16
Passing parameters to a script via WBRun mfilos support.Other 18 14 January 2014 22:29
Passing arguments to scripts Leffmann Coders. General 4 23 January 2009 20:43
Norwegians passing thru OSLO? PLEASE READ :) AmiDelf Amiga scene 0 29 September 2003 15:11

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 19:20.

Top

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