Previous topic |
Next topic |
Ada Home Page |
Index
CHARACTER type
The CHARACTER type is used when you want to represent a single
character. Applications include
- Y/N answer to a question
- menu selection
- etc
Character Sets
binary codes <=> character values
- ASCII (standard)
- EBCDIC (IBM)
- ISO 646 (ASCII + national characters)
- ISO 8859/1 (European languages)
arbitrary, BUT:
- digits contiguous
- lower case letters contiguous
- upper case letters contiguous
CHARACTER values
write in apostrophes:
'A'
'8'
'?'
' '
'''
'"'
NB avoid confusion:
the CHARACTER '1' is not the same as INTEGER 1, or FLOAT 1.0
Attributes of the data type as a whole:
- CHARACTER'FIRST first in character set
- CHARACTER'LAST last in character set
Attributes of individual CHARACTER values:
- CHARACTER'PRED(char)
- PREDecessor
- example: CHARACTER'PRED('N') = 'M'
- CHARACTER'SUCC(char)
- SUCCessor
- example: CHARACTER'SUCC('N') = 'O'
- CHARACTER'POS(char)
- ASCII code
- example: CHARACTER'POS('A') = 65
- CHARACTER'VAL(int)
- character for given code
- example: CHARACTER'VAL(66) = 'B'
CHARACTER operations
Input/Output
- TEXT_IO
- GET
- blanks skipped; ' ' to enter a blank
- PUT
Comparison
- Relational operators compare code values
Other
- character value attributes
Previous topic |
Next topic |
Ada Home Page |
Index
c-lokan@adfa.oz.au / 12 Feb 96