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-Thread: 103376,c31849ae55c4fb65 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Strings and errors... (gnat) From: Georg Bauhaus In-Reply-To: <87u00ip1ip.fsf@ludovic-brenta.org> References: <1164821430.144822.138100@h54g2000cwb.googlegroups.com> <1164823057.036164.238000@h54g2000cwb.googlegroups.com> <87u00ip1ip.fsf@ludovic-brenta.org> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: # Message-Id: <1164886582.14155.13.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Date: Thu, 30 Nov 2006 12:36:22 +0100 NNTP-Posting-Date: 30 Nov 2006 12:36:11 CET NNTP-Posting-Host: c7852663.newsspool1.arcor-online.net X-Trace: DXC=[g`IcO9g1@e9kIfcjg:0fdic==]BZ:afn4Fo<]lROoRa^YC2XCjHcbimAXbR@@c88eA:ho7QcPOVcL2V4]4NiE7g4MLHER@40]k X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:7756 Date: 2006-11-30T12:36:11+01:00 List-Id: On Wed, 2006-11-29 at 19:10 +0100, Ludovic Brenta wrote: > 3) If you are writing a subprogram that splits a given string into 3 > strings of unknown length, you have basically 4 options: > > a) return 3 access values to dynamically allocated strings > b) return 3 unbounded strings > c) return 3 bounded strings > d) return 3 fixed strings and 3 Last values, like > Ada.Text_IO.Get_Line does. > > But simply returning 3 fixed strings will not work. Returning 3 fixed strings will work if you use a suitable type definition: We have "I have input in format String:String:String. I want to get rid of these colons and get three seperate strings." Consider the colon separated input string an object. Hence, procedure fs is type Threefixedstrings (af, al, bf, bl, cf, cl: Natural) is record a: String(af .. al); b: String(bf .. bl); c: String(cf .. cl); end record; function split(Input: String) return Threefixedstrings is separate; begin declare result: constant Threefixedstrings := split("asdf:qwer:cxvbnm"); begin -- do something with result end; end fs; Within the function split you can use Find_Token or Index etc. and collect positions. Then return an aggregate of type Threefixedstrings. There are several variations on this subject. :-) -- Georg