From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,da43b4da51073876 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-24 19:24:09 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc03.POSTED!not-for-mail From: "Steve" Newsgroups: comp.lang.ada References: <1946b526.0302240619.695b865a@posting.google.com> Subject: Re: Help needed; Saving access types with sequential_io? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: NNTP-Posting-Host: 12.211.13.75 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc03 1046143448 12.211.13.75 (Tue, 25 Feb 2003 03:24:08 GMT) NNTP-Posting-Date: Tue, 25 Feb 2003 03:24:08 GMT Organization: AT&T Broadband Date: Tue, 25 Feb 2003 03:24:08 GMT Xref: archiver1.google.com comp.lang.ada:34546 Date: 2003-02-25T03:24:08+00:00 List-Id: "khendon" wrote in message news:1946b526.0302240619.695b865a@posting.google.com... > Hi all [snip] > The only way I can think of is to load the data into temporary string, > and then add those strings to the record. The problem with this is > that those temporary strings need to have a defined length, so when I > add them to the record, they will contain lots of garbage I just don't > want there. That's the whole point of using access types in the record > in the first place, to be able to save strings of different lengths > depending on user input. > > If anyone could provide any help I would be most grateful. > Two common methods for handling this common problem: 1. Precede the data in the string with a fixed size number giving the number of characters in the string. Example: For a record containing the strings "Three" and "Four" the file would contain: 5 'T' 'h' 'r' 'e' 'e' 4 'F' 'o' 'u' 'r' 2. Include a special character as a string separator (C uses nul). Example: For a record containing the strings "Three" and "Four" the file would contain: 'T' 'h' 'r' 'e' 'e' 0 'F' 'o' 'u' 'r' 0 Personally I prefer the first approach since you don't have to scan each character while it is being read, and no characters are off limits for being contained in the string. If you are not writing a program that is time critical (few programes really are), I would suggest using Ada.Strings.Unbounded_String instead of handling your own dynamic allocation and deallocation. I hope this helps, Steve (The Duck) > Regards, Isak