Home > Archive > Rexx > January 2008 > Was I invoked by association or rexx.exe
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Was I invoked by association or rexx.exe
|
|
| Steve Swift 2008-01-26, 4:34 am |
| Can a rexx program know if it was executed by shell association (in
Windows, at least) rather than by explicit use of rexx.exe ?
In other words, can "test.rex" distinguish how it got executed between:
'test.rex'
'rexx.exe test.rex' /* I'd like to detect this one */
Call 'test.rex' /* Easy; use parse source */
Why would I want this?
I execute all my rexx via shell integration. However, my editor has an
Alt-R keystroke that saves the current file, then executes it using:
"rexx.exe [current-file]". This runs in a separate window which closes
when the rexx exits, so I can't see what happened. So I would like to
add a few lines just before the "Exit":
If called_using_rexx.exe() then do
Say 'Press any key to exit'
A = SysGetkey('NOECHO')
End
Exit /* This was here originally */
--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
| |
| Arthur T. 2008-01-26, 7:25 pm |
| In Message-ID:<479c3e9d@news.greennet.net>,
Steve Swift <Steve.J.Swift@gmail.com> wrote:
>Can a rexx program know if it was executed by shell association (in
>Windows, at least) rather than by explicit use of rexx.exe ?
>
>In other words, can "test.rex" distinguish how it got executed between:
>
>'test.rex'
>'rexx.exe test.rex' /* I'd like to detect this one */
>Call 'test.rex' /* Easy; use parse source */
I found a subtle difference which might be of no use to you,
and might be dependant on exact configuration.
/*
Speaking of configuration:
parse version output: REXX-Regina_3.3(MT) 5.00 25 Apr 2004
Microsoft Windows 2000 [Version 5.00.2195]
*/
The name of the program can differ slightly based on whether
it's invoked by just <its name> or, by REXX <its name>.
Example. Program is named HowCall.rex, and it prints the
result of "parse source". Notice the capitalizations in the
following screen-scraping:
13:53 Sat 2008-01-26 F:\>howcall
WIN32 COMMAND F:\HowCall.rex
13:53 Sat 2008-01-26 F:\>howcall.rex
WIN32 COMMAND F:\HowCall.rex
13:53 Sat 2008-01-26 F:\>rexx howcall
WIN32 COMMAND F:\howcall.rex
13:53 Sat 2008-01-26 F:\>rexx howCALL
WIN32 COMMAND F:\howCALL.rex
13:53 Sat 2008-01-26 F:\>HOWcall
WIN32 COMMAND F:\HowCall.rex
In short, being executed by just its name seems to give
"parse source" the exact filename. Being invoked by REXX <name>
seems to give "parse source" the capitalization used on the
command line.
--
Arthur T. - ar23hur "at" intergate "dot" com
Looking for a z/OS (IBM mainframe) systems programmer position
| |
| CyberSimian 2008-01-26, 7:25 pm |
| Steve Swift said:
> Can a rexx program know if it was executed by shell association (in
> Windows, at least) rather than by explicit use of rexx.exe ?
On a Windows command line, enter the following:
Command: ftype rexxscript
Response: rexxscript="C:\Program Files\ooRexx\rexx.exe" "%1" %*
This is displaying the command with which your REXX program is invoked. You
can (of course) add extra parameters to this; these will be added to every
invocation that occurs via the filetype association. Examples:
/* test.rex */
parse arg args
say args
exit 0
With the default definition for REXXScript:
Command: test a b c
Response: a b c
Command: rexx test a b c
Response: a b c
With the definition for REXXScript shown below:
ftype rexxscript="c:\program files\oorexx\rexx.exe" "%1" %* [TESTMODE]
Command: test a b c
Response: a b c [TESTMODE]
Command: rexx test a b c
Response: a b c
The one "gotcha" with this technique is that using the FTYPE command in one
command-line window affects ALL OPEN COMMAND-LINE WINDOWS(!!!), i.e. the
effect is system wide and immediate.
-- from CyberSimian in the UK
| |
| Andreas Schnellbacher 2008-01-26, 7:25 pm |
| On 26.01.08 09:36, Steve Swift wrote:
> Can a rexx program know if it was executed by shell association (in
> Windows, at least) rather than by explicit use of rexx.exe ?
It looks like you use Regina on W$.
The WPS of my OS is able to recognize the different ways. Most likely
also the shell of your OS is able to do that, so you could write a DLL
for that.
> "rexx.exe [current-file]". This runs in a separate window which
> closes when the rexx exits, so I can't see what happened.
Just use this:
cmd.exe /k rexx.exe [current-file]
to keep the command line window open or
cmd.exe /c rexx.exe [current-file]
to close it after execution.
--
Andreas Schnellbacher
| |
| Steve Swift 2008-01-27, 4:39 am |
| Arthur T. wrote:
> In short, being executed by just its name seems to give
> "parse source" the exact filename. Being invoked by REXX <name>
> seems to give "parse source" the capitalization used on the
> command line.
Wow! That's brilliant, and exactly the sort of subtle effect that I was
looking for. It even works with my IBM Object Rexx.
The only snag (and so far a showstopper) is that my editor build the
exact, case-correct call in the command it issues, so masks the effect.
I'll see if the editor can be persuaded to use the filename in lower (or
UPPER) case.
--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
| |
| Steve Swift 2008-01-27, 4:39 am |
| Steve Swift wrote:
> I execute all my rexx via shell integration. However, my editor has an
> Alt-R keystroke that saves the current file, then executes it using:
> "rexx.exe [current-file]". This runs in a separate window which closes
> when the rexx exits, so I can't see what happened.
I've just realised a simple fix for the problem. Instead of my editor
executing the command: "rexx.exe [current-file]" I can make it run the
command "rexx.exe fromedit.rex [current-file]" then inside
"fromedit.rex" I could set an environment variable, and then call
[current-file]
So, the file being edited need only test for the presence of the
environment variable and it knows it has been called from my editor.
I'm still glad that I asked the question though, as I learned a couple
of useful new tricks. So I'm not an old dog after all:
(see http://swiftys.org.uk/images/NewTrick.jpg )
--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
| |
| Glenn Knickerbocker 2008-01-28, 7:42 pm |
| Steve Swift wrote:
> I've just realised a simple fix for the problem. Instead of my editor
> executing the command: "rexx.exe [current-file]" I can make it run the
> command "rexx.exe fromedit.rex [current-file]" then inside
> "fromedit.rex" I could set an environment variable, and then call
> [current-file]
Doesn't [current-file] run in the same window as fromedit.rex? Why mess
with passing anything between them? You can just have fromedit.rex hold
the window open when it's done.
¬R
| |
| Steve Swift 2008-01-29, 4:55 am |
| > Doesn't [current-file] run in the same window as fromedit.rex? Why mess
> with passing anything between them? You can just have fromedit.rex hold
> the window open when it's done.
I thought about that, but some of the programs I edit (then run from the
editor) don't produce any output at all, so there is no point holding
their window open. It has to be down to the routine that gets executed
(and it is quite rare).
--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
| |
| Glenn Knickerbocker 2008-01-29, 7:41 pm |
| Steve Swift wrote:
> editor) don't produce any output at all, so there is no point holding
> their window open.
I'd think you'd want to know if they *did* produce unexpected output,
though. Hmmm, is there anything fromedit.rex could test to find out if
any console output was generated?
¬R
|
|
|
|
|