1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
program Saisie;
uses Crt;
type
TByteOrChar = record
case byte of
0: (C : char);
1: (B : byte);
end;
const
MAP0_32 : array[boolean,#0..#32] of string =
(('NUL','SOH','STX','ETX','EOT','ENQ','ACK','BEL','BS','HT','LF','VT','FF',
'CR','SO','SI','DLE','DC1','DC2','DC3','DC4','NAK','SYN','ETB','CAN','EM',
'SUB','ESC','FS','GS','RS','US','SP'),
('Null','Start of header','Start of text','End of text',
'End of transmission','Enquiry','Acknowledge','Bell','Backspace',
'Horizontal Tab','Line feed','Vertical Tab','Form feed','Carriage Return',
'Shift out','Shift in','Data link escape','Device control 1',
'Device control 2','Device control 3','Device control 4',
'Negative acknowledge','Synchronous idle','End of transmission block',
'Cancel','End of medium','Substitute','Escape','File separator',
'Group separator','Record separator','Unit separator','Space'));
MAP127 : array[boolean] of string = ('DEL','Delete');
function SpCharAscii(const CharCode : char; const UseLongName : boolean) : string;
var
Ret : string;
begin
case CharCode of
#0..#32 : Ret := '('+MAP0_32[UseLongName, CharCode]+')';
#127 : Ret := '('+MAP127[UseLongName]+')';
else
Ret := CharCode;
end;
SpCharAscii := Ret;
end;
var
BOC : TByteOrChar;
S : string;
ErrorFlag : integer;
begin
readln(S);
ErrorFlag := 0;
if Length(S) = 1 then
BOC.C := S[1]
else
Val(S, BOC.B, ErrorFlag);
if ErrorFlag = 0 then
Writlen('Caractère : ', SpCharAscii(BOC.C, false), ' = ', BOC.B:3)
else
Writeln('Erreur de saisie');
end; |
Partager