[Info-vax] VMS Cobol filename issue

Arne Vajhøj arne at vajhoej.dk
Thu Dec 21 18:54:26 EST 2023


On 12/21/2023 5:36 PM, Jim Duff wrote:
> On 22/12/23 01:54, Arne Vajhøj wrote:
>> Even considering that in general I do not understand
>> Cobol, then this one has me puzzled.
>>
>> How does one open a file with the filename being variable?

> By using that value of clause on the FD.  Example:
> 
> identification division.
> program-id. demo.
> 
> environment division.
> input-output section.
> file-control.
>      select in-file assign to junk
>          organization is line sequential.
> 
> data division.
> file section.
> fd in-file
> value of id is file-name
> record is varying in size.
> 01 inrec.
>     03 rec pic x(80).
> 
> working-storage section.
> 01 file-name pic x(20).
> 
> procedure division.
> 0-begin.
>      move "x.x" to file-name.
>      open input in-file.
>      read in-file at end continue.
>      display inrec.
> 0-end.
>      close in-file.
>      stop run.

That is way nicer than lib$set_logical.

Thanks.

Arne





More information about the Info-vax mailing list