From: tmoran@bix.com
Subject: Re: String manipulation question
Date: 1996/05/01
Date: 1996-05-01T00:00:00+00:00 [thread overview]
Message-ID: <4m703q$jnh@news1.delphi.com> (raw)
>as I assume Direct_IO needs an exact byte count of the record
>to find succesive records (makes sense).
>...
>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;
> 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);
>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?)
How about:
Default_User_Record : constant User_Record
:=(UName | Real_Name | Street_Address | City | State | Zip | Phone |
Added | Deleted | Exit_Status | Comments => (1..40=>' '),
FS_Flag => Student);
procedure Fetch(prompt:in string; field:in out string) is
buffer:string(field'range);
last:integer;
begin
Put(prompt);
Get_Line(buffer, last);
-- just fill as much of Field as was entered. Leave the rest alone.
field(field'first .. last):=buffer(buffer'first .. last);
-- if input was as long or longer than buffer, skip to next line
if last = buffer'last then Skip_Line;end if;
end Fetch;
and
data:=Default_User_Record; -- initialize all fields with defaults
Fetch("User Name: ", data.UName);
Fetch("Real Name: ", data.Real_Name);
Fetch("Street Address: ", data.Street_Address);
etc.
next reply other threads:[~1996-05-01 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-05-01 0:00 tmoran [this message]
-- strict thread matches above, loose matches on Subject: below --
1996-04-30 0:00 String manipulation question David Morton
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox