comp.lang.ada
 help / color / mirror / Atom feed
From: pumilia@est.it
Subject: Re: parsing a string
Date: 2000/01/24
Date: 2000-01-24T00:00:00+00:00	[thread overview]
Message-ID: <86h42s$1ht$1@nnrp1.deja.com> (raw)
In-Reply-To: 85q63n$ese$1@bgtnsc01.worldnet.att.net

In article <85q63n$ese$1@bgtnsc01.worldnet.att.net>,
  "James S. Rogers" <jimmaureenrogers@worldnet.att.net> 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.




  reply	other threads:[~2000-01-24  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-15  0:00 parsing a string Paolo M. Pumilia
2000-01-15  0:00 ` James S. Rogers
2000-01-24  0:00   ` pumilia [this message]
2000-01-24  0:00     ` Stephen Leake
2000-01-26  0:00       ` CONTRAINT ERROR (was Re: parsing a string) pumilia
2000-01-26  0:00         ` John English
2000-01-26  0:00         ` Roger Racine
2000-01-26  0:00           ` Fraser
2000-01-26  0:00             ` Simon Wright
2000-01-26  0:00         ` Ian Clifton
2000-01-24  0:00     ` parsing a string Ehud Lamm
2000-01-24  0:00   ` pumilia
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox