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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,db8ef2e54cb04ab9 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!g19g2000yqc.googlegroups.com!not-for-mail From: tonyg Newsgroups: comp.lang.ada Subject: Re: Unbounded String to string Date: Wed, 30 Jun 2010 01:28:50 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6e8fe5aa-d73e-4658-8472-0a1c06aaae83@g19g2000yqc.googlegroups.com> References: <004d7e0b-cf0a-4a71-ac7e-17b61818b910@5g2000yqz.googlegroups.com> <9eec8378-892b-4299-bde7-4f92535f0c20@x21g2000yqa.googlegroups.com> <6137c377-ee81-40af-8d6a-2829ab6dd911@5g2000yqz.googlegroups.com> NNTP-Posting-Host: 89.240.135.62 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1277886530 27674 127.0.0.1 (30 Jun 2010 08:28:50 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 30 Jun 2010 08:28:50 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g19g2000yqc.googlegroups.com; posting-host=89.240.135.62; posting-account=28F2IwkAAACL1Z5nRC-dE7zuvWdbWC7P User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12024 Date: 2010-06-30T01:28:50-07:00 List-Id: On 29 June, 16:19, Adam Beneschan wrote: > On Jun 29, 8:08=A0am, Ludovic Brenta wrote: > > > > > > > tonyg wrote on comp.lang.ada: > > > > On 29 June, 15:33, Adam Beneschan wrote: > > >> On Jun 29, 7:28=A0am, tonyg wrote: > > > >>> Hi, > > >>> =A0 =A0I have an unbounded string from a database I want to turn in= to a 16 > > >>> character subtype of string > > > >>> i.e. unbounded_string to string(1..16) > > > >>> I've been trying to do this most of the afternoon but keep getting > > >>> errors > > > >>> anyone know how ? > > > >> Declare a subtype to give string(1..16) a name; then call To_String > > >> (in Ada.Strings.Unbounded) and convert the function result to your > > >> subtype. =A0E.g.: > > > >> =A0 =A0subtype String_Length_16 is string(1..16); > > >> =A0 =A0V : String_Length_16; > > > >> =A0 =A0V :=3D String_Length_16 (Ada.Strings.Unbounded.To_String (U))= ; > > > That solution only works if U happens to contain exactly 16 > > characters, which is probably not the case if the database really > > contains unbounded strings (i.e. VARCHAR or similar). > > Right, when the OP said he wanted to "turn [an unbounded string] into > a 16 character subtype", I didn't look more deeply into the words > "turn into". =A0I suppose I should have. =A0We'd need to know exactly wha= t > his requirements are to provide a full solution, though--- > specifically, does he expect any unbounded strings to be shorter than > 16 characters, does he expect any of them to be longer than 16 > characters, and if either or both is "yes", what it the desired > behavior in each case. > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Adam I never knew either way and its the first time I have been taking a string from a database - believe it or not all the rest have been numbers up to now :) but thanks to the both of you for your help.