Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Find A Way Of Passing SYS$INPUT To Command File

 
Robert Atkinson
Respected Contributor

Find A Way Of Passing SYS$INPUT To Command File

I've got an interesting problem to tackle. Basically, I want to pass input from SYS$INPUT to a command file in the same way you would pass it to an executable such as SYSMAN.

The structure would look something like this :-

$!
$ @MENU

A
B
C
D
$!
$ EXIT
$!

MENU.COM would then take the A,B,C,D input and use it to create a text file and draw a menu.

I can't think of a way to get the information from the outer layer into the inner layer. Using things like 'TYPE SYS$INPUT' just hangs the command file at that point waiting for input, rather than reading it from the executing procedure.

What I'm ultimately trying to avoid is writing the menu data to disk, so that it can be read in by the menu procedure. Maybe there's a way of using PIPE to put the information into memory and then passing that into the procedure.

Any thoughts on the above would be useful to have.

Rob.
14 REPLIES
The Brit
Honored Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Hi Rob,
Not sure if Im understanding you correctly. If all you want to do is read from the terminal then use;

$ Read sys$command

i.e. command file "testing.com" contains;

$!
$ Read sys$command test
$ show symb Test
$!
$ exit

then

$ @testing
Data: testing
TEST = "testing"
$

The symbol "test" can then be written out to your command file for execution.

Dave


Hein van den Heuvel
Honored Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File


No, Robert wants the lower procedure to read the data lines provided in the higher procedure.
If instead of '@menu' he could use 'run menu' then that would happen.
But a lower command file will try to read the data lines from that lower command file itself.

Looks like this has changed with OpenVMS 7.1-2, and 'fixed' to no longer work at all in 7.2
http://h71000.www7.hp.com/wizard/wiz_5813.html
http://h71000.www7.hp.com/wizard/wiz_4810.html

No it is a bit hard to reason when DCL would read local, or above.

Robert, if menu.com had for example a help construct using
$ TYPE SYS$INPUT
hello world
$ EXIT

Where would you want that data to be read from? How would DCL know?
(Maybe because TYPE is an image?)
You'd almost want an @xxx/INPUT right?

I tried a few logical name assigns to see if I could use a logical name to point to the original stream, but no luck so far... Probably because that file is closed while the lower file runs right (I used to know this stuff... It's been too long! :-).

btw... there is something else odd going on in Alpha 8.3:

------- x.com -------------
$read sys$input x
aap
$show symbol x
$read sys$input x
$show symbol x
$show symbol x
$type sys$input
$show symbol x
$show symbol x
------------------------

This will read 'aap' as expected.
But the next read will not get an EOF, but actually read the command "$show symbol x"
As opposed to TYPE which gets an EOF and types nothing, leaving the 2 lines to execute.

Hein.
Robert Atkinson
Respected Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Apologies guys. It was a difficult problem to describe, and didn't come over very clearly.

There'a a current utility called ZMENU. It can be run like this :-

$!
$! TESTMENU.COM
$!
$ ZMENU

^Option1 ^Option2
^Option3 ^Option4

$ exit
$!

The text in the command file is passed to ZMENU.EXE and interpretted to display a menu on screen. The text can also be passed in a file by running '$ ZMENU MENU_DATA.TXT'

I've written a new version of this that uses the TPU editor to interpret and display the menu.

Running 'EDIT/TPU/SECT=MENU MENU_DATA.TXT' will perform the same function as above. What I'd like to do is replicate the 'on the fly' functionality that ZMENU handles.

The end procedure would look like this :-

$!
$ MENU

^Option1 ^Option2
^Option3 ^Option4

$ exit
$!

Somehow, I need to get the text in the command file into the TPU editor. The MENU verb could be a command file that captures the text somehow, writes it to a file, then passes that to TPU.

The problem I have is writing something that can capture the input.

I DO NOT HAVE ACCESS TO A 'C' COMPILER, before someone starts to give me code.

This may not be possible at all, but I thought it was an intriguing problem and might get people in the group thinking.

Rob.
Robert Atkinson
Respected Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Hein, reading through your post, I think you are right. The '/input' would be the perfect way to resolve the problem but not likely to be available.

The reason I started looking at PIPE to capture the required info is because it appears to read input in a similar way to other EXE's. How to get everything working together is another matter.


> As opposed to TYPE which gets an EOF and
> types nothing, leaving the 2 lines to execute.

I think TYPE may have some specific code in to handle data passed from the command file. We know that as soon as it find the dollar, it stops reading and starts interpreting again, so I reckon this is built into the code.

Rob.
Robert Atkinson
Respected Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Actually, I take that back. '/input' still wouldn't work, as it implies a file, and the data is in the command procedure, not a file.

We almost need some sort of DECK that will allow data to be passed, like this :-

$!
$ @MENU
$ DECK
^A
^B
^C
^D
$ EOD
$ EXIT
$!



$!
$! MENU.COM
$ TYPE /OUT=SYS$TEMP:MENU.TXT SYS$INPUT
$ MENU SYS$TEMP:MENU.TXT
$ EXIT
$!


Unfortunately, DECK doesn't seem to pass data into '@xxx' as it doesn't deem it to be "a command that requires input".

Let me have a play with PIPE and see if that will work.

Rob.
Shilpa K
Valued Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Hi Robert,

Is your requirement to capture the data typed at the command prompt and write it in the same way to a file MENU_DATA.TXT? Then, use this file as an input to execute 'EDIT/TPU/SECT=MENU MENU_DATA.TXT'?

For example, if you type:
A
B

The output of the file MENU_DATA.TXT be as below?
$ type MENU_DATA.TXT
A
B

Regards,
Shilpa
Robert Atkinson
Respected Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Not at the command prompt, but within a command file.
Robert Atkinson
Respected Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Right, I think I've got it.

Due to a quirk of PIPE taking input to the first part of the PIPE command, rather than the last part (trust me on that one), I've come up with this.

It has the downside that even if you pass a pre-created file to MENU, it will still create an empty file as part of the PIPE command, and I have no way of deleting the file afterwards because the input filename has to come at the end of the verb.

It could be improved by having two verbs, one that expects a file to be passed, and one that creates the file from SYS$INPUT on the fly.

Anyway, here it is :-

$!
$ MENU :== PIPE CREATE SYS$TEMP:CHOICE_MENU_'PRCPID'.TXT ; DEFINE/USER/NOLOG MYMENU SYS$TEMP:CHOICE_MENU_'PRCPID'.TXT ; -
DEFINE /USER /NOLOG TPU$CALLUSER 'F$ENV("DEFAULT")'ZSCROLL.EXE ; -
DEFINE /USER /NOLOG SYS$INPUT SYS$COMMAND ; -
EDITA/TPU/NOINIT/COMMAND='F$ENV("DEFAULT")'CHOICE_MENU.INI/SECT='F$ENV("DEFAULT")'ZMENU.TPU$SECTION
$!
$ MENU MYMENU
TEST 1
^A
^B
^C
^D
$!
$ SH SYM CHOICE*
$!
$ MENU TEST.TXT
$ SH SYM CHOICE*
$!

By the way, the utility will soon be available on the Freeware sites, as soon as I've put it into a decent package with some notes.

Rob.
Hein van den Heuvel
Honored Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File


Hmmm,

TPU does not have a way to specify the main input that I can find, other than SYS$INPUT.
Once you redefine that to SYS$COMMAND it can not at the same time be seen as the original sys$input.. the command file. So that's a major challenge.

I tried some PIPE and $CREATE/MAILBOX workaround, but in the end it seems a temporary file was most simple and efficient.
Unless I read your pip stream wrong it seems you are in fact also going that direction.

So why not KISS and move those data lines to be with the CREATE , and not need a pipe At all?

Rough outline below...
Hein.


$MENU :== EDITA/TPU/NOINIT/COMMAND='F$ENV("DEFAULT")'CHOICE_MENU.INI/SECT='F$E
NV("DEFAULT")'ZMENU.TPU$SECTION
$!
$CREATE SYS$TEMP:CHOICE_MENU_'PRCPID'.TXT
TEST 1
^A
^B
^C
^D
$!
$ DEFINE /USER /NOLOG TPU$CALLUSER 'F$ENV("DEFAULT")'ZSCROLL.EXE
$DEFINE /USER /NOLOG SYS$INPUT SYS$COMMAND ;
$ MENU MYMENU
$!
$ SH SYM CHOICE*
$!
$ MENU TEST.TXT
$ SH SYM CHOICE*
$!

Robert Atkinson
Respected Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Although that would simplify things from a programmers perspective, it would make it more cumbersome for the end user (of the utility).

My aim was to keep the new version as true to the old one as possible, so people could swap over with the least effort.

That meant keeping the MENU utility down to a single command from the users point of view, i.e. '$ MENU file.ext'.

I prefer to live with the caveats, and could possibly delete the intermediate TXT file from within TPU to help with the cleanup.

Rob.
Andy Bustamante
Honored Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Pipe may be useful:

$!
$ pipe ( write sys$output "A" ; write sys$output "B" ; write sys$output "C" ; write sys$output "D" ) | @MENU
$!
$ exit

Andy
If you don't have time to do it right, when will you have time to do it over? Reach me at first_name + "." + last_name at sysmanager net
John Gillings
Honored Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Rob,
You can use PIPE in lots of creative ways.

Here's a self recursive procedure that I believe does what you want. I've put a TYPE SYS$INPUT command at the point you would run your program.

MENU.COM
$ verf='F$VERIFY(F$TRNLNM(F$PARSE(F$ENVIRONMENT("PROCEDURE"),,,"NAME")+"_VERIFY"))
$ self=F$PARSE(";",F$ENVIRONMENT("PROCEDURE"))
$ stat=1
$ IF F$EXTRACT(0,1,p1).EQS."#"
$ THEN
$ target=p1-"#"
$ GOTO 'target'
$ ENDIF
$
$ PIPE @'self' #TEXT | @'self' #MENU SYS$PIPE
$
$ GOTO FinExit
$
$ TEXT:
$ TYPE SYS$INPUT
$ DECK

A
B
C
D
$ EOD
$ GOTO FinExit
$
$ MENU:
$ in=p2
$ IF in.EQS."" THEN in="SYS$COMMAND"
$ DEFINE/USER SYS$INPUT 'in'
$! RUN ZMENU
$ TYPE SYS$INPUT
$ GOTO FinExit
$
$ DEBUG:
$ VERIFY:
$ DEFINE/NOLOG 'name'_'target' TRUE
$ IF p2.NES.""
$ THEN
$ @'self' "''p2'" "''p3'" "''p4'" "''p5'" "''p6'" "''p7'" "''p8'"
$ stat=$STATUS
$ GOTO NO'target'
$ ENDIF
$ GOTO FinExit
$ NODEBUG:
$ NOVERIFY:
$ target=target-"NO"
$ IF F$TRNLNM("''name'_''target'").NES."" THEN DEASSIGN 'name'_'target'
$ GOTO FinExit
$
$ FinExit:
$ EXIT %X10000000.OR.F$INTEGER(stat)+(F$VERIFY(verf).AND.0)


Run with

$ @MENU

to get the menu using the canned ABCD input.

$ @MENU #MENU

will use your specified input file. If omitted, defaults to SYS$COMMAND

Realise that the TEXT branch could contain other commands (like WRITE SYS$OUTPUT), so you can feed variable input into the MENU branch.
A crucible of informative mistakes
John Gillings
Honored Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

Rob,
Just a couple of other tricks you may find useful...

>$ MENU :== PIPE CREATE SYS$TEMP:CHOICE_MENU_'PRCPID'.TXT ;

F$UNIQUE is a good way to generate filenames, but the returned string is quite long, so it's usually best to use the file type to distinguish related files. So:

$ u=F$UNIQUE()
$ txt=F$PARSE(".TXT;",u,"SYS$TEMP")

>DEFINE /USER /NOLOG TPU$CALLUSER 'F$ENV("DEFAULT")'ZSCROLL.EXE ; -

As above, use F$PARSE to generate file specifications. Presumably your use of F$ENVIRONMENT("DEFAULT") means your procedure must have SET DEFAULT to the directory containing your images? If they're in the same directory as the procedure itself, start with:

$ self= F$PARSE(";",F$ENVIRONMENT("PROCEDURE"))

you now have a locator, thus:

DEFINE /USER /NOLOG TPU$CALLUSER 'F$PARSE("ZSCROLL.EXE",self)' ; -

this may help you write code that is independent of, and does not change, the current default directory.

A crucible of informative mistakes
Robert Atkinson
Respected Contributor

Re: Find A Way Of Passing SYS$INPUT To Command File

OK, I didn't really get to the solution I would have preferred, but this is as close as it gets.

Many thanks for your help with this people. CHOICE will be available on the Freeware sites shortly.

Rob.


$ MENU :== PIPE CREATE CHOICE$SCRATCH:CHOICE_INPUT_'F$GETJPI("","PID")'.TXT ; -
IF F$TYPE(CHOICE_LINE) .NES. """""" THEN DELETE /SYM/GLOB/NOLOG CHOICE_LINE ; -
IF F$TYPE(CHOICE_OPTION) .NES. """""" THEN DELETE /SYM/GLOB/NOLOG CHOICE_OPTION ; -
PURGE /NOLOG CHOICE$SCRATCH:CHOICE_INPUT_'F$GETJPI("","PID")'.TXT ; -
DEFINE/USER/NOLOG MYMENU CHOICE$SCRATCH:CHOICE_INPUT_'F$GETJPI("","PID")'.TXT ; -
DEFINE/USER/NOLOG TPU$CALLUSER CHOICE$SYSTEM:CHOICE.EXE ; -
DEFINE/USER/NOLOG SYS$INPUT SYS$COMMAND ; -
EDITA/TPU/NOINIT/COMMAND=CHOICE$INI:CHOICE_MENU.INI/SECT=CHOICE$SYSTEM:CHOICE.TPU$SECTION