I don't unterstand __byte__ :-(
11 Sep 1996 14:06:00 +0200
Hi all,
the following example I've used to test the __byte__ and __short__ types.
There was some trouble while using the GRX20-library (I'm working on a
interface-unit) with conversion of different structures.
Look at my sample and say me why I can't get the correct value from Bytes.
program ByteTest;
const
arHex : array[0..$0f] of char
= '0123456789abcdef';
max = 15;
type
WrkStr = String(255);
var
a32 : array[0..max] of Integer;
a16 : array[0..max] of __short__ Integer absolute a32;
a8 : array[0..max] of __byte__ Integer absolute a32;
a_c : array[0..max] of char absolute a32;
i : Integer;
function hexa(number: Integer): WrkStr;
var
i : Integer;
s : WrkStr;
begin
s := '';
for i := 1 to 8 do begin
s := arHex[number and $0f] + s;
number := number shr 4;
end;
hexa := ' $'+s;
end;
begin
for i := 0 to max do a_c[i] := chr(i);
for i := 0 to max do begin
write(i: 3);
write(ord(a_c[i]): 5);
write(a8[i]: 10);
if i mod 2 = 0 then
write(a16[i div 2]: 10);
if i mod 4 = 0 then
write(a32[i div 4]: 16);
writeln;
end;
for i := 0 to max do begin
write(i: 3);
write(hexa(ord(a_c[i])));
write(hexa(a8[i]));
if i mod 2 = 0 then
write(hexa(a16[i div 2]));
if i mod 4 = 0 then
write(hexa(a32[i div 4]));
writeln;
end;
end.
I'm using the DJGPP-GPC on MS-DOS and that's the output:
0 0 34560 256 50462976
1 1 34561
2 2 34562 770
3 3 34563
4 4 34564 1284 117835012
5 5 34565
6 6 34566 1798
7 7 34567
8 8 34568 2312 185207048
9 9 34569
10 10 34570 2826
11 11 34571
12 12 34572 3340 252579084
13 13 34573
14 14 34574 3854
15 15 34575
0 $00000000 $00000000 $00000100 $03020100
1 $00000001 $00000001
2 $00000002 $00000002 $00000302
3 $00000003 $00000003
4 $00000004 $00000004 $00000504 $07060504
5 $00000005 $00000005
6 $00000006 $00000006 $00000706
7 $00000007 $00000007
8 $00000008 $00000008 $00000908 $0b0a0908
9 $00000009 $00000009
10 $0000000a $0000000a $00000b0a
11 $0000000b $0000000b
12 $0000000c $0000000c $00000d0c $0f0e0d0c
13 $0000000d $0000000d
14 $0000000e $0000000e $00000f0e
15 $0000000f $0000000f
Please don't quote the whole text !!!
___,
((__ o
,____)) V E N I
Sven Hilscher (Sven@rufus.central.de (Sven Hilscher))
HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada -
Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es