comp.lang.ada
 help / color / mirror / Atom feed
* Reading variable-length records from a file
@ 2001-08-10 18:37 Brian Catlin
  2001-08-10 19:04 ` Larry Kilgallen
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Brian Catlin @ 2001-08-10 18:37 UTC (permalink / raw)


What is the best method for reading variable-length records from a file, using Ada (generic Ada, or GNAT)?  I have some files, from
a VMS system, that I want to read on a Win2K system.  The files have the VMS standard "implied carriage control", which means that
each "record" (or line; it's a text file) has a two-byte count value, followed by "count" bytes (characters).

 -Brian






^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reading variable-length records from a file
  2001-08-10 18:37 Reading variable-length records from a file Brian Catlin
@ 2001-08-10 19:04 ` Larry Kilgallen
  2001-08-10 21:28 ` Mark Johnson
  2001-08-13  8:14 ` Thierry Lelegard
  2 siblings, 0 replies; 9+ messages in thread
From: Larry Kilgallen @ 2001-08-10 19:04 UTC (permalink / raw)


In article <9l19l4$45m$1@slb7.atl.mindspring.net>, "Brian Catlin" <briancatlin@mindspring.com> writes:
> What is the best method for reading variable-length records from a file, using Ada (generic Ada, or GNAT)?  I have some files, from
> a VMS system, that I want to read on a Win2K system.  The files have the VMS standard "implied carriage control", which means that
> each "record" (or line; it's a text file) has a two-byte count value, followed by "count" bytes (characters).

And a fill byte if needed to even the count.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reading variable-length records from a file
  2001-08-10 18:37 Reading variable-length records from a file Brian Catlin
  2001-08-10 19:04 ` Larry Kilgallen
@ 2001-08-10 21:28 ` Mark Johnson
  2001-08-13  8:14 ` Thierry Lelegard
  2 siblings, 0 replies; 9+ messages in thread
From: Mark Johnson @ 2001-08-10 21:28 UTC (permalink / raw)


Brian Catlin wrote:

> What is the best method for reading variable-length records from a file, using Ada (generic Ada, or GNAT)?  I have some files, from
> a VMS system, that I want to read on a Win2K system.  The files have the VMS standard "implied carriage control", which means that
> each "record" (or line; it's a text file) has a two-byte count value, followed by "count" bytes (characters).
>
>  -Brian

An ugly way to do it would be to write a "VMS_get_line" procedure to...
 - read the two characters to generate the line length (c2'pos*256+c1'pos)
 - read that many characters (and Pad as Larry mentioned)
and call that in lieu of Text_IO.Get_Line.

(or are you looking for a plug replacement so you can use Integer_IO... that would be harder)

  --Mark
PS: I could make a snide comment about it being easier to do in C, but that would be flame bait.






^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reading variable-length records from a file
  2001-08-10 18:37 Reading variable-length records from a file Brian Catlin
  2001-08-10 19:04 ` Larry Kilgallen
  2001-08-10 21:28 ` Mark Johnson
@ 2001-08-13  8:14 ` Thierry Lelegard
  2001-08-13 17:39   ` Brian Catlin
  2 siblings, 1 reply; 9+ messages in thread
From: Thierry Lelegard @ 2001-08-13  8:14 UTC (permalink / raw)


> What is the best method for reading variable-length records from a file, using Ada (generic Ada, or GNAT)?  I have some files, from
> a VMS system, that I want to read on a Win2K system.  The files have the VMS standard "implied carriage control", which means that
> each "record" (or line; it's a text file) has a two-byte count value, followed by "count" bytes (characters).

How do you move the file from VMS to Windows?

If you use FTP, simply specify "ASCII mode" instead of "IMAGE mode"
during the transfer and you will get a plain Windows text file.

If you share the file system (NFS, Samba), make sure that the file 
is created with the "stream" or "stream_lf" attribute (use FDL options).

Otherwise, if you can't modify the way the file is created, you can
convert it on VMS using the following DCL procedure. This changes
the physical content while preserving the logical one. After conversion,
the file remains a valid text file on VMS but is also Windows-compliant.

$ convert/fdl=sys$input: 'infile' 'outfile'
        file
          organization sequential
        record
          block_span yes
          carriage_control carriage_return
          format stream
$

We work in an heterogeneous environment (VMS + UNIX + Windows) and
we share all Ada source files (text files) on the same file system
without problem.

-Thierry
____________________________________________________________________________

Thierry Lelegard, "The Jazzing Troll", Email: thierry.lelegard@canal-plus.fr
CANAL+ Technologies, 34 place Raoul Dautry, 75906 Paris Cedex 15, France
Tel: +33 1 71 71 54 30   Fax: +33 1 71 71 52 08   Mobile: +33 6 03 00 65 75
____________________________________________________________________________



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reading variable-length records from a file
  2001-08-13  8:14 ` Thierry Lelegard
@ 2001-08-13 17:39   ` Brian Catlin
  2001-08-13 18:29     ` tmoran
  2001-08-13 18:51     ` Larry Kilgallen
  0 siblings, 2 replies; 9+ messages in thread
From: Brian Catlin @ 2001-08-13 17:39 UTC (permalink / raw)


Unfortunately, the files were ZIPped up and sent to me; I don't have a VMS system to perform the conversion.  Therefore, I want to
write an Ada program to convert the files for me.  I could have written a C program to do this in the time it took for me to write
the original post, but I want to "get both lobes around the Ada paradigm", and do it in Ada.  So far, the only suggestion on
actually doing the conversion in Ada was to read two characters, multiply the first by 256, add them together, and then read that
number of characters from the file.  GROSS!  There has to be a better way!

 -Brian

"Thierry Lelegard" <thierry.lelegard@canal-plus.fr> wrote in message news:3B778C6E.9B43450D@canal-plus.fr...
> > What is the best method for reading variable-length records from a file, using Ada (generic Ada, or GNAT)?  I have some files,
from
> > a VMS system, that I want to read on a Win2K system.  The files have the VMS standard "implied carriage control", which means
that
> > each "record" (or line; it's a text file) has a two-byte count value, followed by "count" bytes (characters).
>
> How do you move the file from VMS to Windows?
>
> If you use FTP, simply specify "ASCII mode" instead of "IMAGE mode"
> during the transfer and you will get a plain Windows text file.
>
> If you share the file system (NFS, Samba), make sure that the file
> is created with the "stream" or "stream_lf" attribute (use FDL options).
>
> Otherwise, if you can't modify the way the file is created, you can
> convert it on VMS using the following DCL procedure. This changes
> the physical content while preserving the logical one. After conversion,
> the file remains a valid text file on VMS but is also Windows-compliant.
>
> $ convert/fdl=sys$input: 'infile' 'outfile'
>         file
>           organization sequential
>         record
>           block_span yes
>           carriage_control carriage_return
>           format stream
> $
>
> We work in an heterogeneous environment (VMS + UNIX + Windows) and
> we share all Ada source files (text files) on the same file system
> without problem.
>
> -Thierry
> ____________________________________________________________________________
>
> Thierry Lelegard, "The Jazzing Troll", Email: thierry.lelegard@canal-plus.fr
> CANAL+ Technologies, 34 place Raoul Dautry, 75906 Paris Cedex 15, France
> Tel: +33 1 71 71 54 30   Fax: +33 1 71 71 52 08   Mobile: +33 6 03 00 65 75
> ____________________________________________________________________________





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reading variable-length records from a file
  2001-08-13 17:39   ` Brian Catlin
@ 2001-08-13 18:29     ` tmoran
  2001-08-13 18:51     ` Larry Kilgallen
  1 sibling, 0 replies; 9+ messages in thread
From: tmoran @ 2001-08-13 18:29 UTC (permalink / raw)


> Unfortunately, the files were ZIPped up and sent to me;
  Do you mean with pkzip?  If so, I'd expect pkzip options to convert.

> program to convert the files for me.  I could have written a C program to
> do this in the time it took for me to write the original post,
> ...
> the only suggestion on actually doing the conversion in Ada was to read
> two characters, multiply the first by 256, add them together, and then
> read that number of characters from the file.  GROSS!  There has to be a
> better way!
  For those of us too dense to see the better way, could you please
show (the important parts of) the C code you would use?  Perhaps there's
a clever trick that could also be used in Ada.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reading variable-length records from a file
  2001-08-13 17:39   ` Brian Catlin
  2001-08-13 18:29     ` tmoran
@ 2001-08-13 18:51     ` Larry Kilgallen
  1 sibling, 0 replies; 9+ messages in thread
From: Larry Kilgallen @ 2001-08-13 18:51 UTC (permalink / raw)


In article <9l93cp$bbf$1@slb7.atl.mindspring.net>, "Brian Catlin" <briancatlin@mindspring.com> writes:
> Unfortunately, the files were ZIPped up and sent to me; I don't have a VMS system to perform the conversion.  Therefore, I want to

Does ZIP have a notion of text files ?  It sounds like they were
ZIPped as binary.

> write an Ada program to convert the files for me.  I could have written a C program to do this in the time it took for me to write
> the original post, but I want to "get both lobes around the Ada paradigm", and do it in Ada.  So far, the only suggestion on
> actually doing the conversion in Ada was to read two characters, multiply the first by 256, add them together, and then read that
> number of characters from the file.  GROSS!  There has to be a better way!

Plus one if needed to make it an even number.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reading variable-length records from a file
@ 2001-08-13 21:29 Gautier Write-only-address
  2001-08-13 22:41 ` Larry Kilgallen
  0 siblings, 1 reply; 9+ messages in thread
From: Gautier Write-only-address @ 2001-08-13 21:29 UTC (permalink / raw)
  To: comp.lang.ada

Larry Kilgallen:

>Does ZIP have a notion of text files ?

Yes. Anyway you can force the unzipping as a text,
on the target system.
________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: Do not answer to sender address, visit the Web site!
    Ne r�pondez pas � l'exp�diteur, visitez le site ouaibe!



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Reading variable-length records from a file
  2001-08-13 21:29 Gautier Write-only-address
@ 2001-08-13 22:41 ` Larry Kilgallen
  0 siblings, 0 replies; 9+ messages in thread
From: Larry Kilgallen @ 2001-08-13 22:41 UTC (permalink / raw)


In article <mailman.997738222.22248.comp.lang.ada@ada.eu.org>, "Gautier Write-only-address" <gautier_niouzes@hotmail.com> writes:
> Larry Kilgallen:
> 
>>Does ZIP have a notion of text files ?
> 
> Yes. Anyway you can force the unzipping as a text,
> on the target system.

For the case at hand, though, the decision must be made when the
zipping is done, on the sending system.  No user interaction is
required as the file on the VMS system clearly indicates its
format.



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-08-13 22:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-10 18:37 Reading variable-length records from a file Brian Catlin
2001-08-10 19:04 ` Larry Kilgallen
2001-08-10 21:28 ` Mark Johnson
2001-08-13  8:14 ` Thierry Lelegard
2001-08-13 17:39   ` Brian Catlin
2001-08-13 18:29     ` tmoran
2001-08-13 18:51     ` Larry Kilgallen
  -- strict thread matches above, loose matches on Subject: below --
2001-08-13 21:29 Gautier Write-only-address
2001-08-13 22:41 ` Larry Kilgallen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox