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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,564a91823edb719c X-Google-Attributes: gid103376,public From: pumilia@est.it Subject: Re: parsing a string Date: 2000/01/24 Message-ID: <86h42s$1ht$1@nnrp1.deja.com>#1/1 X-Deja-AN: 576819862 References: <388095E5.6BF46237@cstc.org> <85q63n$ese$1@bgtnsc01.worldnet.att.net> X-Http-Proxy: 1.0 x29.deja.com:80 (Squid/1.1.22) for client 212.239.48.35 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Mon Jan 24 08:56:00 2000 GMT X-MyDeja-Info: XMYDJUIDpumilia Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.7 [en] (X11; I; Linux 2.2.13 i686) Date: 2000-01-24T00:00:00+00:00 List-Id: In article <85q63n$ese$1@bgtnsc01.worldnet.att.net>, "James S. Rogers" wrote: > Paolo M. Pumilia wrote in message <388095E5.6BF46237@cstc.org>... > >I am rather new to Ada programming. A hint would be useful to quickly > >translate a procedure > >that i am used to use in fortran programs. > >How to split a string (or unbounded string) into a character array, > >using blanks as separators? > > There are a lot of ways to do this. The easiest is to use the package > Ada.Strings.Fixed. For this question you will want to use the > Index function. It will return the index of the first occurance of the > pattern you want to find. > Thank you for help. i have found the function Index, defined as follows function Index (Source : in String; Pattern : in String; Going : in Direction := Forward; Mapping : in Maps.Character_Mapping := Maps.Identity) return Natural; in package Ada.Strings.Fixed I guessed that the last two fields are set by default, so that it is possible not to pass them any value. Maybe it is a wrong guess, but i do not know what value can be passed for Maps.Character_Mapping Here is a selection from my test procedure 'dimer.adb', where the string output_file has been assigned by another procedure: with ada.strings.unbounded; use ada.strings.unbounded; with ada.strings.fixed; use ada.strings.fixed; ... output_file : unbounded_string ; part1_output_file : string (1..25) ; ... output_file := to_string(output_file); Index(part1_output_file,"put"); ... Here is the output from the GNAT compiler: % gnatgcc -c -O3 dimer.adb > dimer.adb:143:04: invalid parameter list in call (use -gnatf for details) > gnatmake: "dimer.adb" compilation error % gnatgcc -c -O3 -gnatf dimer.adb > dimer.adb:143:04: no candidate interpretations match the actuals: > dimer.adb:143:04: missing argument for parameter "Mapping" in call to "index" declared at a-strfix.ads:68 > dimer.adb:143:04: missing argument for parameter "Mapping" in call to "index" declared at a-strunb.ads:186 I can try the statement Index(total_output_file,"put", forward); but i do not know what to specify as "Mapping" Thank you for your help Paolo Pumilia Sent via Deja.com http://www.deja.com/ Before you buy.