Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
170 user(s) are online (157 user(s) are browsing Forums)

Members: 1
Guests: 169

hlt, more...

Support us!

Headlines

 
  Register To Post  

Arexx question - putting the output of a DOS command into a variable
Not too shy to talk
Not too shy to talk


See User information
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.

Go to top
Re: Arexx question - putting the output of a DOS command into a variable
Not too shy to talk
Not too shy to talk


See User information
@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(fileLastPos('/',file))
if 
path "" then path=Left(fileLastPos(':',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
Go to top
Re: Arexx question - putting the output of a DOS command into a variable
Not too shy to talk
Not too shy to talk


See User information
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

Go to top
Re: Arexx question - putting the output of a DOS command into a variable
Not too shy to talk
Not too shy to talk


See User information
@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().

Go to top
Re: Arexx question - putting the output of a DOS command into a variable
Just can't stay away
Just can't stay away


See User information
@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

Go to top

  Register To Post

 




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




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project