Who's Online |
53 user(s) are online ( 31 user(s) are browsing Forums)
Members: 2
Guests: 51
walkero, eliyahu,
more...
|
|
Headlines |
-
arabic_console_devicepro2.lha - driver/input
Aug 9, 2022
-
kittymusicraft.library.lha - development/library
Aug 8, 2022
-
amiarcadia.lha - emulation/gamesystem
Aug 8, 2022
-
amosextension.library.lha - library/misc
Aug 8, 2022
-
luettjebookholler.lha - office/misc
Aug 6, 2022
-
mce.lha - game/utility
Aug 5, 2022
-
ign-addon-ods.lha - office/spreadsheet
Aug 5, 2022
-
avalanche_deu.lha - utility/archive
Aug 4, 2022
-
mednafen.lha - emulation/gamesystem
Aug 3, 2022
-
avalanche.lha - utility/archive
Aug 3, 2022
|
|
|
|
Arexx question - putting the output of a DOS command into a variable
|
|
Just popping in 
Joined: 2008/10/18 11:25 Last Login
: Today 5:35
From Auckland, New Zealand
Group:
Registered Users
|
Hi, I am trying to write an arexx script that uses Requeststring to get a string from a user, but I'm struggling to get it to work properly. From what I've read, this should work:
/*Clone*/
OPTIONS RESULTS
address command 'c:requeststring title "Clone" body "Enter filename to clone to"'
newname = RESULT
But it doesn't, the value of newname is RESULT. I have found a method using rxset that works but means I can't enter a DEFSTRING, and I guess I could write the output to a file and read it, but I'm intrigued as to why this doesn't work.
|
|
|
|
Re: Arexx question - putting the output of a DOS command into a variable
|
|
Just popping in 
Joined: 2008/10/18 11:25 Last Login
: Today 5:35
From Auckland, New Zealand
Group:
Registered Users
|
@daveyw Well, I got my method using rxset to do what I wanted, so this is kinda moot now, but still curious why I can't get a RESULT.
/* Clone */
OPTIONS RESULTS
OPTIONS FAILAT 21
SIGNAL ON ERROR
parse arg file
path=Left(file, LastPos('/',file))
if path = "" then path=Left(file, LastPos(':',file))
oldfile=delstr(file,1,length(path))
oldfile=Left(oldfile,length(oldfile)-1)
address command
cmd = ' title "Clone" body "Enter filename to clone to" DEFSTRING "'||oldfile||'"'
rxset reqres "`"requeststring cmd"`"
newfile=getclip(reqres)
call setclip(reqres,'')
cmd = 'c:copy from '||file||' to '||path||newfile'" >nil:'
address command cmd
EXIT
ERROR:
address command 'c:requestchoice "Abort" "Cloning aborted" "OK" >NIL:'
EXIT
Edited by daveyw on 2022/5/25 22:04:18
|
|
|
|
Re: Arexx question - putting the output of a DOS command into a variable
|
|
Not too shy to talk 
Joined: 2006/12/2 1:41 Last Login
: 6/26 0:04
From VA, USA
Group:
Registered Users
|
Hey Davyw,
Ever the fan of doing things the longhand way, here's a chunk of code I've used often. You can paste this in a text file and test it in the CLI.
--- /* Ask User Choice & Print Out */ TitleBarTxt = 'Test Requester' BodyTxt = 'Pick something!' ButtonsTxt = '"Yes" "Umm" "No"' ReqType = 'INFO' cline = 'c:requestchoice "' || (TitleBarTxt) || '" "' || BodyTxt || '" ' || (ButtonsTxt) || ' TYPE ' || (ReqType) || ' TO T:response.txt' address command cline MyReturnCode = RC if exists('T:response.txt') then if open(ReqF,'T:response.txt','r') then do pick = strip(readln(ReqF),'B','"') bs = close(ReqF) address command 'c:delete T:response.txt' say 'response >' pick '<' end else say 'Couldn''t open Requester output file' ---
[meh -- tabs were stripped -- imagine they're there ]
Of course this can be adapted to RequestString or RequestFile. The RC/ReturnCode lets you see if the user cancelled the requester in those cases, IIRC.
Good luck,
PJS
|
|
|
|
Re: Arexx question - putting the output of a DOS command into a variable
|
|
Just popping in 
Joined: 2008/10/18 11:25 Last Login
: Today 5:35
From Auckland, New Zealand
Group:
Registered Users
|
@pjs
Thanks for that. Yeah, if I had gone down the route of writing the response to a file and then reading it, that's a decent bit of code.
I'm a bit wary of that way of doing things, though, when I wrote a script that wrote a fair amount of data to a file and then tried to parse bits of it into variables. I found that it would fall over, and I suspected it was because it was trying to read the file before it was finished writing. I did a quick and dirty workaround with a wait, but I really need to figure out how to use EOF().
|
|
|
|
Re: Arexx question - putting the output of a DOS command into a variable
|
|
Just can't stay away 
Joined: 2008/1/6 17:56 Last Login
: 7/31 22:27
From Pennsylvania, USA
Group:
Registered Users
|
@daveyw I found this in ARexxReference:
/* Example: code snippet by Christoph Gutjahr - c.gutjahr@gmx.de
-------
Assuming you have the dos command program "requeststring"... */
cmdid='req'pragma('id')
address command 'rxset' cmdid '`requeststring "TITLE" "BODY"`'
inputstring=getclip(cmdid)
say inputstring
call setclip(cmdid,'')
I added the say command to confirm it works.
|
Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450
|
|
Currently Active Users Viewing This Thread:
1
(
0 members
and 1 Anonymous Users
)
|
|
|