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,38c827f7e800d317 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-27 11:42:27 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc02.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: conversion References: <3EFC45BE.5030904@attbi.com> X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 12.234.13.56 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc02 1056739346 12.234.13.56 (Fri, 27 Jun 2003 18:42:26 GMT) NNTP-Posting-Date: Fri, 27 Jun 2003 18:42:26 GMT Organization: AT&T Broadband Date: Fri, 27 Jun 2003 18:42:26 GMT Xref: archiver1.google.com comp.lang.ada:39846 Date: 2003-06-27T18:42:26+00:00 List-Id: >Hmmm. Where to begin. You are thinking in C about Ada concepts. That >is confusing you because the Ada mappings are different. In Ada, the As a general rule, if something seems inordinately hard to do in Ada, you are probably not using Ada appropriately. In the case of strings, declaring dynamically sized strings, passing strings as dynamically sized parameters, using concatenation, and, especially, using slices will handle a great many string processing tasks. eg, procedure Process_Line(Line : in String) is -- From "Fred Smith #12345; John Jones, Albert" -- make 2 calls on Process_First_Name -- Process_Full_Name("Smith, Fred"); -- Process_Full_Name("Jones, John"); First, Last : Natural; begin First := Line'first; loop Ada.Strings.Fixed.Find_Token (Source=>Line(First .. Line'last), Set =>Ada.Strings.Maps.Constants.Letter_Set, Test =>Ada.Strings.Inside, First =>First, Last =>Last); exit when Last = 0; declare use Ada.Strings; use Ada.Strings.Maps.Constants; First_Name : String renames Line(First .. Last); begin Fixed.Find_Token(Line(Last+1 .. Line'last), Letter_Set, Inside, First, Last); exit when Last = 0; Process_Full_Name(Line(First .. Last) & ", " & First_Name); end; First := Last+1; end loop; end Process_Line; ... Line : String(1 .. 80); Last : Natural; ... Ada.Text_IO.Get_Line(Input, Line, Last); Process_Line(Line(Line'first .. Last));