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.
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.
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().