Subject: | |
From: | |
Reply To: | |
Date: | Thu, 18 Apr 1996 17:32:52 GMT |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Ken Hirsch ([log in to unmask]) wrote:
: Mark Landin ([log in to unmask]) wrote:
: : Is there an example of how to do mapped file access in COBOL
: : floating around on the net somewhere? I'd like to play around with
: : it.
: : --
: : Mark Landin "If you choose not to decide,
: : Systems Manager you still have made a choice"
: : Superstar Satellite Entertainment -Neil Peart, RUSH
: I must note that it is possible to do SHORT-mapped file access in COBOL.
: This has the following disadvantages:
: (1) File size is limited (to 4MB, I think)
: (2) You can only open a limited number of files this way.
: Does anybody have details on this? Is this adjustable in SYSGEN?
: (3) While you have a file opened for short-mapped access, it cannot
: be opened in any other way.
: While COBOL (unfortunately) has no support for pointers per se, you can
: lie to your subprograms since COBOL has no type-checking for subprogram
: parameters.
: You need to open the file for short-mapped access with a 32-bit pointer.
: 01 short-pointer pic s9(9) comp.
Pointers are unsigned 32 bit integers. By declaring s9(9) comp the
sign-bit is ignored causing problems. It would be safe to make it X(04).
Milind Gole
[log in to unmask]
: Then, when you call your program, pass this by VALUE.
: call "MYSUBPROG" using \short-pointer\
: In your subprogram linkage section, you can make this whatever you want:
: id division.
: program-id. mysubprog.
: data division.
: linkage section.
: 01 large-array.
: 05 my-record occurs 4096 times.
: 10 my-name pic x(30).
: 10 my-addr pic x(30).
: 10 your-states-name-here pic x(30).
: etc.
: procedure division using large-array.
: your-code-goes-here.
: You can use this technique to use pointers in general including memory
: that you malloc()!
: If the mapped file does actual disk I/O, Scott Gavin is right that
: mapped-access is not much faster. However, if the file is present in
: memory, mapped-file access is MUCH faster.
: You still must handle EOF via intrinsics. And, if more than one process
: accesses the file at the same time, you still must contol access
: somehow.
: Ken Hirsch
: Carrboro, NC
|
|
|