HP3000-L Archives

April 1996, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Ken Hirsch <[log in to unmask]>
Reply To:
Ken Hirsch <[log in to unmask]>
Date:
Tue, 16 Apr 1996 08:43:29 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (59 lines)
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.
 
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

ATOM RSS1 RSS2