comp.lang.ada
 help / color / mirror / Atom feed
* incrementing characters
@ 1998-07-08  0:00 Jamie
  1998-07-09  0:00 ` Dmitriy Anisimkov
  1998-07-10  0:00 ` Pascal MALAISE
  0 siblings, 2 replies; 3+ messages in thread
From: Jamie @ 1998-07-08  0:00 UTC (permalink / raw)


Hi,

I'm new to Ada and would like a small problem solved if possible,

how can I increment the value of a character? If you know what I mean - if
character FIRST has the value 'A' how can I increment it so that its value
is now 'B' ?

I'm looking to do something like this,

character := character + offset

where offset is a constant integer.

Can anyone help???????

Cheers,

Jamie.

j.couston@virgin.net




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

* Re: incrementing characters
  1998-07-08  0:00 incrementing characters Jamie
@ 1998-07-09  0:00 ` Dmitriy Anisimkov
  1998-07-10  0:00 ` Pascal MALAISE
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitriy Anisimkov @ 1998-07-09  0:00 UTC (permalink / raw)
  To: Jamie

Jamie wrote:
> how can I increment the value of a character?

Char := Character'Succ(Char); -- next value
Char := Character'Pred(Char); -- previous value
Char := Character'Val(Character'Pos(Char)+offset); -- integer offset




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

* Re: incrementing characters
  1998-07-08  0:00 incrementing characters Jamie
  1998-07-09  0:00 ` Dmitriy Anisimkov
@ 1998-07-10  0:00 ` Pascal MALAISE
  1 sibling, 0 replies; 3+ messages in thread
From: Pascal MALAISE @ 1998-07-10  0:00 UTC (permalink / raw)


Jamie wrote:
 
> character := character + offset
function UPPER_CHAR (CHAR : CHARACTER) return CHARACTER is
  OFFSET  : constant INTEGER   := CHARACTER'POS('A') -
CHARACTER'POS('a');
begin

  if CHAR in 'a' .. 'z' then
-- This is what you are looking for?
    return CHARACTER'VAL( CHARACTER'POS(CHAR) + OFFSET );
  else
    return CHAR;
  end if;
end UPPER_CHAR;


-- 
Pascal MALAISE		| E-mail:
22 Avenue de CHOISY	|  (priv) malaise@magic.fr
75013 PARIS		|  (prof) malaise@fr.airsysatm.thomson-csf.com
FRANCE




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

end of thread, other threads:[~1998-07-10  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-07-08  0:00 incrementing characters Jamie
1998-07-09  0:00 ` Dmitriy Anisimkov
1998-07-10  0:00 ` Pascal MALAISE

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