Deutsch   English   Français   Italiano  
<67a2c6de$0$713$14726298@news.sunsite.dk>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Tue, 4 Feb 2025 21:03:10 -0500
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Cobol
Newsgroups: comp.os.vms
References: <vlkm45$2fe4n$1@dont-email.me> <vlmt72$2vndn$1@dont-email.me>
 <vlmto2$2v5n1$2@dont-email.me> <vlmub7$2vndn$2@dont-email.me>
 <vln74b$318c0$3@dont-email.me> <vlohc5$3cc83$1@dont-email.me>
 <67855f5f$0$714$14726298@news.sunsite.dk> <vm43g7$225rp$1@dont-email.me>
 <vm45lv$22lsd$1@dont-email.me>
 <eeca502210e0692c317347c3aca2e109866d6026@i2pn2.org>
 <vm621v$2fb43$2@dont-email.me> <67a01dee$0$713$14726298@news.sunsite.dk>
 <67a03039$0$713$14726298@news.sunsite.dk>
Content-Language: en-US
From: =?UTF-8?Q?Arne_Vajh=C3=B8j?= <arne@vajhoej.dk>
In-Reply-To: <67a03039$0$713$14726298@news.sunsite.dk>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 115
Message-ID: <67a2c6de$0$713$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 030ff385.news.sunsite.dk
X-Trace: 1738720991 news.sunsite.dk 713 arne@vajhoej.dk/68.14.27.188:62125
X-Complaints-To: staff@sunsite.dk
Bytes: 4716

On 2/2/2025 9:55 PM, Arne Vajhøj wrote:
> On 2/2/2025 8:37 PM, Arne Vajhøj wrote:
>> On 2/2/2025 8:30 PM, Arne Vajhøj wrote:
>>  > On 1/14/2025 11:06 AM, Arne Vajhøj wrote:
>>  >> On 1/13/2025 9:11 PM, John Reagan wrote:
>>  >>> COBOL paragraphs behave like C.  First routine/PARAGRAPH gets a WEAK
>>  >>> transfer address.  Linker finds the first one.
>>  >>
>>  >> I have many prejudices about COBOL developers.
>>  >>
>>  >> One of them is that they don't create shareable images.
>>  >>
>>  >> :-)
>>  >
>>  > But let us say that someone wanted to create a shareable
>>  > image in Cobol.
>>  >
>>  > A typical Cobol program just have all the paragraphs that
>>  > get performed and they share state. Simple.
>>  >
>>  > To make them entry points with arguments in a shareable image,
>>  > then I assume one need to make them programs with linkage section
>>  > and procedure division using.
>>  >
>>  > Normal variables are just passed as arguments. Seems entirely
>>  > unproblematic to me.
>>  >
>>  > But how does one share open files between modules?
>>  >
>>  > Fortran and Basic numeric identifiers work across modules.
>>  > Pascal can share via inherit. C can use global variables
>>  > or just pass as argument.
>>  >
>>  > But how does one do that in Cobol?
>>  >
>>  > Can one mark an fd as global or can one pass a fd as argument?
>>
>> Did some reading.
>>
>> IS GLOBAL in one module and IS EXTERNAL in the other modules?
> 
> And what to put in SELECT if FD is EXTERNAL?

Just EXTERNAL everywhere and no GLOBAL and nothing on SELECT
seems to do the trick.

identification division.
program-id.m2.
*
environment division.
input-output section.
file-control.
     select in-file assign to "a.dat" organization is sequential.
     select out-file assign to "c.dat" organization is sequential.
*
data division.
file section.
fd in-file external record is varying in size depending on line-len.
01 in-record.
     03 in-line pic x(100).
fd out-file external record is varying in size from 0 to 100 depending 
on line-len.
01 out-record.
     03 out-line pic x(100).
working-storage section.
01 line-len pic 9(8) comp external.
*
procedure division.
main-paragraph.
     open input in-file
     open output out-file
     call "docopy" end-call
     close in-file
     close out-file
     stop run.
end program m2.
*
identification division.
program-id. docopy.
*
environment division.
input-output section.
file-control.
     select in-file assign to "a.dat" organization is sequential.
     select out-file assign to "c.dat" organization is sequential.
*
data division.
file section.
fd in-file external record is varying in size depending on line-len.
01 in-record.
     03 in-line pic x(100).
fd out-file external record is varying in size from 0 to 100 depending 
on line-len.
01 out-record.
     03 out-line pic x(100).
working-storage section.
01 line-len pic 9(8) comp external.
01 eof-flag pic x.
*
procedure division.
main-paragraph.
     move "N" to eof-flag
     perform until eof-flag = "Y"
         read in-file
             at end
                 move "Y" to eof-flag
             not at end
                 move in-line(1:line-len) to out-line
                 write out-record
         end-read
     end-perform.
end program docopy.

Arne