comp.lang.ada
 help / color / mirror / Atom feed
From: David Morton <dmorton@jinx.sckans.edu>
Subject: String manipulation question
Date: 1996/04/30
Date: 1996-04-30T00:00:00+00:00	[thread overview]
Message-ID: <318614BC.2DB3B88C@jinx.sckans.edu> (raw)


First, thanks to all who have replied to my previous two posts...

Now I have a new problem.
I'm making a database program (from scratch, to learn how)
and need to put the fields in a file
using direct_IO.  As expected, Unbounded_Strings
did not work with Direct_IO, as I assume Direct_IO
needs an exact byte count of the record to find succesive
records (makes sense).

So for strings, I have to use a bounded string...
for my purposes, let's say 1..20.
Right now, I have to "mask" out the parts of the string that doesn't
get used like so:

 type F_S_Flag is (Faculty, Student);   
 type User_Record is record
        UName, Real_Name, Street_Address, City, State, Zip, Phone,
        Added, Deleted, Exit_Status, Comments : String(1..40);
        FS_Flag : F_S_Flag;
 end record;
 User_Record_Mask : User_Record :=
    ("                                        ",
     "                                        ",
     "                                        ",
     "                                        ",
     "                                        ",
     "                                        ",
     "                                        ",
     "                                        ",
     "                                        ",
     "                                        ",
     "                                        ",
     Student);



        Put("User Name: ");
        Get_Line(data.UName,Last);
        data.Uname(Last+1..data.Uname'Last) :=
        User_Record_Mask.Uname(Last+1..User_Record_Mask.Uname'Last);

 this    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
seems messy, but it must be done in order to maintain the constant length.
Null terminated strings would work, but isn't the implentation of it in Ada
just as messy as this? (How would you implement it?)

Thanks!

-- 
David Morton
 mailto:dmorton@jinx.sckans.edu    // If you use Netscape 2.0,
 205 College, Winfield, KS 67156   // you can click on the mailto: part to reply!
                                   (HINT, HINT)  :)





             reply	other threads:[~1996-04-30  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-30  0:00 David Morton [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-05-01  0:00 String manipulation question tmoran
replies disabled

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