veck@ddsw1.MCS.COM (Steven P. King) (12/30/90)
Rexx question for the peanut gallery. ARexx, actually. Is there a way to get single character input from the keyboard? PULL wants a carriage return. I'm trying to write a program in which it's pretty vital to have single keystroke commands. And as long as we're on the subject... Is there some easy way to get the output from shell commands into an ARexx program? I cut my teeth on Rexx under VM/CMS, where you could (STACK or (QUEUE the output of most external commands, to be read into Rexx by simple PULL statements. Is there some similar mechanism on the Amiga? Or better, under csh on Unix I can do things like "set x = `date`", which executes the "date" command and assigns the output to the variable 'x'. I'd absolutely LOVE this kind of expansion from within ARexx. -- -----------------------------------------------------+------------------------ So Bill, tell us about holographic food. | Steven King | Software Archaeologist | veck@ddsw1.MCS.COM
psop@watcsc.waterloo.edu (Paul Sop) (12/31/90)
In article <1990Dec30.035944.1472@ddsw1.MCS.COM> veck@ddsw1.MCS.COM (Steven P. King) writes: >Rexx question for the peanut gallery. ARexx, actually. Is there a way to >get single character input from the keyboard? PULL wants a carriage return. >I'm trying to write a program in which it's pretty vital to have single >keystroke commands. No kidding. The only way I've gotten around this is to hack in a handler that will append an end of line after every letter the person types. (It's in a serial handler though) >And as long as we're on the subject... Is there some easy way to get the >output from shell commands into an ARexx program? I cut my teeth on Rexx >under VM/CMS, where you could (STACK or (QUEUE the output of most external >commands, to be read into Rexx by simple PULL statements. Is there some >similar mechanism on the Amiga? Or better, under csh on Unix I can do >things like "set x = `date`", which executes the "date" command and assigns >the output to the variable 'x'. I'd absolutely LOVE this kind of expansion >from within ARexx. Simple. Very simple. I wrote a shell in AREXX which lets me do this quite easily. I'm in a good mood, so I even went to the trouble of cutting out the procedure and pasting together an example. It's pretty much self explanitory: Procedure: Shellit Arguments: 1 Valid DOS command Returns: # of lines of output generated -1 if no output lines generated. Modifies: Stem variable "Command" Command.0 = # of lines of output. Command.1 = first line of output, command.2 = 2nd... Anyway, here's a program which uses the procedure: /* Shellit.REXX -PD By Paul Sop- */ /* Runs DOS command and puts output in stem variable command */ options prompt "Shell What? " parse pull command say say "The output for this command is:" say if shellit(command) >0 then do i = 1 to command.0 say command.i end exit 0 shellit: procedure expose command. /* Shell an argument to DOS but put output in stem variable command. */ /* Command.0 contains the # of lines of output */ parse arg command lines = 0 if command ~="" then do address command word(command,1) ">t:shellit.tmp" delword(command,1,1) if open("shellit", "t:shellit.tmp", "R") then do until eof("shellit") lines = lines + 1 command.lines = readln("shellit") end end command.0 = lines - 1 call close "shellit" return command.0 The output of the program would look like this: Shell What? ls -l shell* The output for this command is: -----rwxd 3 747 Dec 31 05:15 shellit.rexx -----rwxd 1 0 Dec 31 05:15 shellit.tmp Files: 2 Blocks: 4 Bytes: 747 You're welcome. :-)
hammond@cs.albany.edu (William F Hammond) (12/31/90)
In a previous article Steven P. King writes: > From: veck@ddsw1.MCS.COM (Steven P. King) > Date: 30 Dec 90 03:59:44 GMT > Organization: Macro Computer Solutions, Inc. - Wheeling, IL > > Rexx question for the peanut gallery. ARexx, actually. Is there a way to > get single character input from the keyboard? PULL wants a carriage return. > I'm trying to write a program in which it's pretty vital to have single > keystroke commands. > I don't think it can be done reading the console, but one can open a "RAW:" window and then readch(window_logical, 1). In fact, here's a sample that works: /* tf */ erf = open(ip, "raw:20/20/113/29/Input/", 'R') if erf ~= 1 then do say "Cannot open input window." exit 5 end thischr = readch(ip, 1) do while ~EOF(ip) if thischr = '0d'x then do call close(ip) exit 0 end say "Received '" || thischr || "'." thischr = readch(ip,1) end exit 0 You might be able to do something along this line also by opening a window using rexxarplib calls. > And as long as we're on the subject... Is there some easy way to get the > output from shell commands into an ARexx program? I cut my teeth on Rexx > under VM/CMS, where you could (STACK or (QUEUE the output of most external > commands, to be read into Rexx by simple PULL statements. Is there some > similar mechanism on the Amiga? Or better, under csh on Unix I can do > things like "set x = `date`", which executes the "date" command and assigns > the output to the variable 'x'. I'd absolutely LOVE this kind of expansion > from within ARexx. The simplest most straightforward thing in a "stripped" Amiga OS 1.3 environ- ment is to pass info in a file in "RAM:" (or via "PIPE:"). Of course, some of the things available through shell commands are also available through ARexx function calls. Things become much nicer if your command shell has an ARexx port. (For example, "WShell" by William S. Hawes, the author of ARexx.) ---------------------------------------------------------------------- William F. Hammond Dept. of Mathematics & Statistics 518-442-4625 SUNYA, Albany, NY 12222 hammond@leah.albany.edu wfh58@albnyvms.bitnet ----------------------------------------------------------------------
dfrancis@tronsbox.xei.com (Dennis Heffernan) (12/31/90)
In article <1990Dec30.222612.4636@watcsc.waterloo.edu> psop@watcsc.waterloo.edu (Paul Sop) writes: >In article <1990Dec30.035944.1472@ddsw1.MCS.COM> veck@ddsw1.MCS.COM (Steven P. King) writes: >>Rexx question for the peanut gallery. ARexx, actually. Is there a way to >>get single character input from the keyboard? PULL wants a carriage return. >>I'm trying to write a program in which it's pretty vital to have single >>keystroke commands. > >No kidding. The only way I've gotten around this is to hack in a handler >that will append an end of line after every letter the person types. >(It's in a serial handler though) > Um, I did this by opening a RAW window and just doing readch(window,1). CON didn't work; again, it wanted returns. If you don't want or can't have a RAW window floating around, though... dfrancis@tronsbox.xei.com ...uunet!tronsbox!dfrancis GEnie: D.HEFFERNAN1 "...when Fortran was introduced, it was claimed that Fortran would largely eliminate coding and debugging! Of course, that claim proved to be quite false" - UNIVERSAL ASSEMBLY LANGUAGE, Robert M. Fitz & Larry Crocket
kleist@nemesis.bula.se (Svante Kleist) (12/31/90)
In article <1990Dec30.035944.1472@ddsw1.MCS.COM> veck@ddsw1.MCS.COM (Steven P. King) writes: ( - - - ) >And as long as we're on the subject... Is there some easy way to get the >output from shell commands into an ARexx program? I cut my teeth on Rexx >under VM/CMS, where you could (STACK or (QUEUE the output of most external >commands, to be read into Rexx by simple PULL statements. Is there some >similar mechanism on the Amiga? Or better, under csh on Unix I can do >things like "set x = `date`", which executes the "date" command and assigns >the output to the variable 'x'. I'd absolutely LOVE this kind of expansion >from within ARexx. > > Since You use an Amiga, that is really straightforward. Use "ExecIO", which is supplied with W. Hawes' "WShell". I cite from the WShell manual: - - - EcecIO ------ The ExecIO program is a powerful multi-purpose filter program whose basic operation is a line-oriented copy between an input and output stream. /---/ if invoked from within an ARexx macro program it can transfer information directly into the macro program's variables. /---/ ARexx macro programs frequently need to capture the output from an AmigaDOS command for further processing. Although there are several ways to do this, it's often most convenient to use WShell's piping in conjunction with the ExecIO program /---/. ExecIO has a direct interface to a macro program's variables and can copy from its input stream into a stem variable that you provide. - - - Good luck, and Happy New Year! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . S V A N T E K L E I S T . . . . Student of Computer Systems Sciences, Univ. of Stockholm, Sweden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
jdege@ (Jeff Dege) (01/03/91)
In article <1990Dec30.035944.1472@ddsw1.MCS.COM> veck@ddsw1.MCS.COM (Steven P. King) writes: >Rexx question for the peanut gallery. ARexx, actually. Is there a way to >get single character input from the keyboard? PULL wants a carriage return. >I'm trying to write a program in which it's pretty vital to have single >keystroke commands. > This isn't an Arexx question, it's an AmigaDOS question. Every console handler performs some degree of massaging of input. The standard console in cooked mode allows for command line editting, etc. Nothing gets sent to the application until it sees a newline. The answer, of course, is to either open a new console in raw mode or to set the current console to raw mode. The first is easy. Just call open with a 'raw:0/0/100/100/' filename. The second is more difficult.You need to send an ACTION_SCREEN_MODE packet to the console handler. I have code to do this in C, I have no idea how to do it in REXX. (There is a package in the PD for AREXX called ALIBHOST that allows you to access any system function, so it can obviously be done, but I've never done it.) --------------------------------