Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

adding characters

0 views
Skip to first unread message

Roman Töngi

unread,
Dec 19, 2007, 10:28:19 AM12/19/07
to
I have no pascal environment and do not want
to install one just for this question.

Is this a valid expressen:

'A' + 'A'

yielding 130 if ord('A') = 65

thx

scott moore

unread,
Dec 19, 2007, 11:18:14 AM12/19/07
to

ord('A') + ord('A')

or

chr(ord('A') + ord('A'))

If you want the result to also be a character.

Pascal is a typed language. 'A'+'A' is asking the
compiler to add two characters which is not possible,
since it has no meaning. In reality, you are asking
to add the character codes together, and you are asking
the compiler to automatically convert the characters to
their integer equivalents.

Pascal does not have a problem with that, it just wants
you to explicitly state what you are doing.

CBFalconer

unread,
Dec 19, 2007, 10:37:42 PM12/19/07
to

No. 'A' is a character, not a number. However:

ord('A') + ord('A')

will yield a number. What it is depends on your system.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

0 new messages