HP3000-L Archives

February 2000, Week 2

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:
Reply To:
Date:
Fri, 11 Feb 2000 20:37:24 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (146 lines)
Hi,
As Stan says, the padding may occur when you read the record,
What is little known and somtimes confusing is that it depends
on the way you open the file.

If your file is built with, say, ;REC=-1000,1,V,ASCII but you open it
with the fixed-length record option,
Eg.,        f:=fopen(fname,%007)
                len:=fread(f,buf,-1000);
This will always return len=1000, and the buffer padded out with blanks,
even if the actual record on file contains only 3 or 4 bytes.

Clearly, this padding is a waste of cpu cycles if your record lengths
are typically much less than 1000, especially if you have gone to the
trouble of removing trailing blanks when you wrote the records in
the first place.
I have seen programs perform very badly indeed because of this,
where quite often, to compound the problem, the program initializes
the whole buffer to spaces before each read !

Assuming that the record length of 1000 does actually represent the length
of the largest possible record, the correct or better  thing to do is open the
file
with the variable length record option ie.,  f:=fopen(f,%107);
or use a file equation with the REC= parameter setting 'variable length'
explicitly.
In this case, the FREAD just returns the record length as it is in the file,
and does not do the padding.


Note that this feature is the same for standard variable length record files
and message files.

Regards,
Tad.










Internet

From:     [log in to unmask] on 11/02/2000 17:45 GMT



Pour :    HP3000-L

cc :

ccc:  Tad BOCHAN

Objet :   Re: Message files




Re:

> BUILD MSTEST;MSG;REC=-1000,,V,ASCII;DISC=10000
>
> that MPE pads your variable length writes to the file with spaces (or binary
> zeros if the file is defined as Binary rather than ascii) - effectively making
> this a fixed length file of 1000 bytes !

No, it doesn't do such padding.

Proof:

   :BUILD MSTEST;MSG;REC=-1000,,V,ASCII;DISC=10000
   :fcopy from=;to=mstest

   HP31900A.05.02 FILE COPIER (C) HEWLETT-PACKARD CO. 1990

   *200*WARNING: FROMFILE RECSIZE IS 80 BYTES, TOFILE RECSIZE IS 1000 BYTES.
   CONTINUE OPERATION (Y OR N) ? Y
   short
   longggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
    < CONTROL Y >

   2 RECORDS PROCESSED *** 0 ERRORS

   End Run
   :debug
   DEBUG/iX C.16.01

   $1 ($58) nmdebug > map mstest
   1  MSTEST.SOURCE.SIELER   950.0 Bytes = 98b1d8
   $2 ($58) nmdebug > dv 95.0, 20,s, e
   VIRT $950.0        "..short .Plonggggggggggggggggggggggggggggggggggggggggggg"
   VIRT $950.38       "gggggggggggggggggggggggggggg  ...
   $3 ($58) nmdebug > unmap 1

What you may be seeing is that when you READ the message file,
records are padded to the file's record size.

   :fcopy from=mstest;to=;hex

   MSTEST RECORD 0 (%0, #0)

   0000: 7368 6F72 7420 2020 2020 2020 2020 2020 2020 2020 2020 2020
   000C: SAME: TO 01F4-1

   MSTEST RECORD 1 (%1, #1)

   0000: 6C6F 6E67 6767 6767 6767 6767 6767 6767 6767 6767 6767 6767
   000C: SAME: TO 0018-1
   0018: 6767 6767 6767 6767 6767 6767 6767 6720 2020 2020 2020 2020
   0024: SAME: TO 01F4-1
   EOF FOUND IN FROMFILE AFTER RECORD 1

Both records came from the file as though they're $1f4 halfwords long
($1f4 * 2 = #1000 bytes)

Stan




Stan Sieler                                           [log in to unmask]
www.allegro.com/sieler/wanted/index.html          www.allegro.com/sieler





-----------------------------------------------------------------------------
This message is confidential; its contents do not constitute a
commitment by Paribas except where provided for in a written agreement
between you and Paribas. Any unauthorised disclosure, use or
dissemination, either whole or partial, is prohibited. If you are not
the intended recipient of the message, please notify the sender
immediately.

Ce message est confidentiel ; son contenu ne représente en aucun cas un
engagement de la part de Paribas sous réserve de tout accord conclu par
écrit entre vous et Paribas. Toute publication, utilisation ou
diffusion, même partielle, doit être autorisée préalablement. Si vous
n'êtes pas destinataire de ce message, merci d'en avertir immédiatement
l'expéditeur.

ATOM RSS1 RSS2