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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d10c964e990dddc9 X-Google-Attributes: gid103376,public From: Simon Johnston Subject: Re: Help me parse a long character Date: 1997/11/03 Message-ID: <01BCE863.95E32930.skj@acm.org>#1/1 X-Deja-AN: 287579043 Sender: Ada programming language Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU Reply-To: "skj@acm.org" Newsgroups: comp.lang.ada Date: 1997-11-03T00:00:00+00:00 List-Id: Use the Index function in Ada.Strings.Fixed, like so: the first bit will get you the last name, and then the first name. You can then use the resulting four values to substring your original to get two shorter strings. Note this relies on at least one space between LASTNAME and FIRSTNAME and a trailing space after FIRSTNAME - if this is not the case then you'll have to add some code :) declare Start_Of_LASTNAME : Natural; End_Of_LASTNAME : Natural; Start_Of_FIRSTNAME : Natural; End_Of_FIRSTNAME : Natural; begin Start_Of_LASTNAME := Full_Name_String'First; End_Of_LASTNAME := Natural'Pred(Ada.Strings.Fixed.Index(Full_Name_String, " ")); Start_Of_FIRSTNAME := Ada.Strings.Fixed.Index_Non_Blank(Full_Name_String(End_Of_LASTNAME .. Full_Name_String'Last)); End_Of_FIRSTNAME := Natural'Pred(Ada.Strings.Fixed.Index(Full_Name_String(Start_Of_FIRSTNAME .. Full_Name_String'Last))); end ; -----Original Message----- From: DHBemis [SMTP:dhbemis@AOL.COM] Sent: Saturday, October 25, 1997 8:48 PM To: INFO-ADA@LISTSERV.NODAK.EDU Subject: Help me parse a long character This is an easy one I'm sure. I'm in my first semester of programming.... I'm trying to parse a 40-character long string. They are formatted in the following way: LASTNAME^^^^^^^^^^^^^^^^^FIRSTNAME^^^^^^ <--- the variable Full_Name I'm not sure how to parse it into to two separate variables, first_name and Last_name. I used the get_line procedure to get the string, so I have the last_character position. How do I ignore the spaces in between? Thanks ! Help