[Info-vax] VMS Cobol filename issue

Arne Vajhøj arne at vajhoej.dk
Thu Dec 21 13:32:07 EST 2023


On 12/21/2023 1:19 PM, Arne Vajhøj wrote:
> On 12/21/2023 12:24 PM, jeffrey_dsi wrote:
>> On 12/21/23 06: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?
> 
>> The only way I've seen to make the filename in Cobol a variable is to 
>> use a logical.
>>
>> ASSIGN TO "TEST"
>>
>> and before the program is run
>>
>> $ DEFINE TEST PROD_DATA:MYFILE.DAT
> 
> Thanks.
> 
> Really weird.
> 
> I ended up with:
> 
> file-control.
>      select in-file assign to "INFNM" organization is line sequential.
> ...
> working-storage section.
> 01 infnm pic x(5) value "INFNM".
> 01 cmd pic x(80).
> 01 cmdlen pic s9(8) comp.
> 01 tbl pic x(11) value "LNM$PROCESS".
> ...
> procedure division.
> main-paragraph.
>      call "lib$get_foreign" using by descriptor cmd, omitted, by 
> reference cmdlen
>      call "lib$set_logical" using by descriptor infnm, by descriptor 
> cmd(1:cmdlen), by descriptor tbl
>      open input in-file

tbl is not necessary - LNM$PROCESS is default.

Arne





More information about the Info-vax mailing list