Solved How to assign sys$input to a file, for more than one command

September 11, 2014 at 08:02:13
Specs: n/a, n/a
I have the following command file:

$define sys$input strip.inp
$strip
$strip

The "strip" command reads a set of input parameters from strip.inp. The first command correctly reads the first set of input parameters. The intended action is that the second command would read the next set of input parameters which follow the first set in strip.inp. However, it instead (apparently) re-opens strip.inp and reads the first set again.

How do I modify the "define" command so that the intended action happens?


See More: How to assign sys$input to a file, for more than one command

Report •


#1
September 15, 2014 at 09:24:08
✔ Best Answer
THe use of the DEFINE or ASSIGN command only direct sys$input to a specific file, not to any particular recrd within that file. Each invokation of the STRIP program will start just like any other, at the first record of the file. If STRIP is expecting to only handle a single record at a time, than the only way to accomplish what yuou want is to allow a command procedure to manage the records and file rather than STRIP. You would need to Open the file from DCL (See the OPEN verb in help) and to READ the record into a symbol (See DCL READ verb in help). Write the record to a temporary file and than use the define to point to the temporary file. When complete, close (See DCL CLOSE verb) and loop to get the next record. (DCL READ can detect the EOF so you can exit normally.)

I hope this helps point you in the right direction.

Dan


Report •

#2
September 15, 2014 at 11:55:13
Thank you for the reply. It answers my question, just not in the way I was hoping...

Joe


Report •

#3
September 16, 2014 at 06:46:04
Not knowing what the strip program actually does, I can only speculate here, but...

It should be relatively easy to modify the strip to take a parameter from the command line or to read a logical name or symbol to get the record number to read. In this fashion, the syumbol or logical name can be updated after each "strip" command. Strip can than resolve that value to indicate the record number to read.

If you don't know how to do this, send me the program and I can either make it into a foreign command that takes a parameter (I'll include instructions on how to do this) or modify it to check for a logical name for the record number.

This means that one of the following would work:

Case 1:

$ num = 1
$ loop:
$ assign 'num recnum
$ strip
$ num = num + 1
$ if num .lt. 100 then goto loop
$ exit


Case 2:

$ num = 1
$ loop:
$ strip 'num
$ num = num + 1
$ if num .lt. 100 then goto loop
$ exit

Let me know what you need.

Dan


Report •

Related Solutions


Ask Question