comp.lang.ada
 help / color / mirror / Atom feed
* Character Handling
@ 2000-04-30  0:00 Robert Stephen Breen
  2000-04-30  0:00 ` Ken Garlington
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Robert Stephen Breen @ 2000-04-30  0:00 UTC (permalink / raw)


Hi everyone,
I am currently working on an assigment at uni and I have to convert a
String input to upper case. I have discovered that package
Characters.Handling will do the trick, however mebe its because I am
Irish, but I can not make heads or tails of how you actually use it in
your code!

I have put

With Text_io,Ada.Characters.Handling;
Use Text_io;

and in one of my procedures I have tried to convert an input.

Ada.Characters.Handling.To_upper(Clients_Name(Name_Last)) etc

all I get is a message stating Ivalid parameter call ? How

could someone please explain!!!!!!!!!!!!!!!!!

Thanks
Rob





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Character Handling
  2000-04-30  0:00 Character Handling Robert Stephen Breen
  2000-04-30  0:00 ` Ken Garlington
@ 2000-04-30  0:00 ` DuckE
  2000-04-30  0:00 ` Marin D. Condic
  2 siblings, 0 replies; 4+ messages in thread
From: DuckE @ 2000-04-30  0:00 UTC (permalink / raw)


The function To_Upper is a function that takes a string as an argument and
returns a string.  Here's a working sample program that uses
Ada.Characters.Handling.To_Upper:

-- == Start of file: DemoHandling.adb =========
WITH Ada.Characters.Handling;

WITH Ada.Text_Io;

PROCEDURE DemoHandling IS

PACKAGE Text_Io RENAMES Ada.Text_Io;

PACKAGE Handling RENAMES Ada.Characters.Handling;

inputText : String(1..80);

lastIndex : Natural;

BEGIN

Text_Io.Put( "Enter Text > " );

Text_Io.Get_Line( inputText, lastIndex );

DECLARE

ucText : String := Handling.To_Upper( inputText(1..lastIndex) );

lcText : String := Handling.To_Lower( inputText(1..lastIndex) );

BEGIN

Text_Io.Put_Line( "Upper case: " & ucText );

Text_Io.Put_Line( "Lower case: " & lcText );

END;

END DemoHandling;

--========End of File: DemoHandling.adb=============

I hope this helps,
SteveD

"Robert Stephen Breen" <emages@cantech.net.au> wrote in message
news:390D1159.83CAEA7F@cantech.net.au...
> Hi everyone,
> I am currently working on an assigment at uni and I have to convert a
> String input to upper case. I have discovered that package
> Characters.Handling will do the trick, however mebe its because I am
> Irish, but I can not make heads or tails of how you actually use it in
> your code!
>
> I have put
>
> With Text_io,Ada.Characters.Handling;
> Use Text_io;
>
> and in one of my procedures I have tried to convert an input.
>
> Ada.Characters.Handling.To_upper(Clients_Name(Name_Last)) etc
>
> all I get is a message stating Ivalid parameter call ? How
>
> could someone please explain!!!!!!!!!!!!!!!!!
>
> Thanks
> Rob
>






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Character Handling
  2000-04-30  0:00 Character Handling Robert Stephen Breen
@ 2000-04-30  0:00 ` Ken Garlington
  2000-04-30  0:00 ` DuckE
  2000-04-30  0:00 ` Marin D. Condic
  2 siblings, 0 replies; 4+ messages in thread
From: Ken Garlington @ 2000-04-30  0:00 UTC (permalink / raw)


"Robert Stephen Breen" <emages@cantech.net.au> wrote in message
news:390D1159.83CAEA7F@cantech.net.au...
> Hi everyone,
> I am currently working on an assigment at uni and I have to convert a
> String input to upper case. I have discovered that package
> Characters.Handling will do the trick, however mebe its because I am
> Irish, but I can not make heads or tails of how you actually use it in
> your code!
>
> I have put
>
> With Text_io,Ada.Characters.Handling;
> Use Text_io;
>
> and in one of my procedures I have tried to convert an input.
>
> Ada.Characters.Handling.To_upper(Clients_Name(Name_Last)) etc
>
> all I get is a message stating Ivalid parameter call ? How
>
> could someone please explain!!!!!!!!!!!!!!!!!
>
> Thanks
> Rob
>

OK: According to the language manual, section A.3.2, there are two such
functions:

function To_Upper (Item : in Character) return Character;
function To_Upper (Item : in String) return String;

So:

1. If Clients_Name(Name_Last) is a neither a character nor a string (e.g. an
access value), then it is invalid regardless of the context.

2. If Clients_Name(Name_Last) is a character, then you should be using
To_Upper in a context where it should be returning a character.

3. If Clients_Name(Name_Last) is a string, then you should be using To_Upper
in a context where it should be returning a string.







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Character Handling
  2000-04-30  0:00 Character Handling Robert Stephen Breen
  2000-04-30  0:00 ` Ken Garlington
  2000-04-30  0:00 ` DuckE
@ 2000-04-30  0:00 ` Marin D. Condic
  2 siblings, 0 replies; 4+ messages in thread
From: Marin D. Condic @ 2000-04-30  0:00 UTC (permalink / raw)


Robert Stephen Breen wrote:
> 
> Hi everyone,
> I am currently working on an assigment at uni and I have to convert a
> String input to upper case. I have discovered that package
> Characters.Handling will do the trick, however mebe its because I am
> Irish, but I can not make heads or tails of how you actually use it in
> your code!
> 
> I have put
> 
> With Text_io,Ada.Characters.Handling;
> Use Text_io;
> 
> and in one of my procedures I have tried to convert an input.
> 
> Ada.Characters.Handling.To_upper(Clients_Name(Name_Last)) etc
> 
> all I get is a message stating Ivalid parameter call ? How
> 
You don't have sufficient information here to diagnose the exact
problem. The answer is that it depends o what the function (I'm
presuming its a function) Clients_Name returns. A correct usage of the
call would be:

....
String_1 : String (1..10) := "abcdefghik" ;
String_2 : String (1..10) ;
....
String_2 := Ada.Characters.Handling.To_Upper (String_1) ;
....


Note that the sizes and types of both String_1 and String_2 match. Note
that they are of the type "String" which is the expected type as an
input parameter to the function "To_Upper". Ada is very fussy that all
the types match. It may seem like a pain, but this is how Ada can catch
otherwise hard to diagnose errors in program logic.

If you need additional examples, I've got lots of Ada code on my web
page. Look specifically at the code under  GNAT_Examples.chop where I
have lots of small programs that illustrate basic Ada features.

MDC
-- 
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

"I'd trade it all for just a little more"
    --  Charles Montgomery Burns, [4F10]
======================================================================




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-04-30  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-30  0:00 Character Handling Robert Stephen Breen
2000-04-30  0:00 ` Ken Garlington
2000-04-30  0:00 ` DuckE
2000-04-30  0:00 ` Marin D. Condic

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