Page 1 of 1
Integer <> Character Casts
Posted: Fri Aug 07, 2009 2:14 pm
by ConvertFromOldNGs
by David Mitchell >> Thu, 6 May 1999 2:11:43 GMT
Here's a tip I discovered when playing around with binary files:
If you have a character like so:
vars
chr : Character;
and you say :
i := chr.Integer;
then i gets the ASCII value for chr. This also works the other way. So if i is 65 then
chr := i.Character;
makes chr = 'A'.
Neats huh?
David.
Re: Integer <> Character Casts
Posted: Fri Aug 07, 2009 2:14 pm
by ConvertFromOldNGs
by Kevin Alcock >> Thu, 6 May 1999 3:30:07 GMT
Also try i := 321;
even cooler
Re: Integer <> Character Casts
Posted: Fri Aug 07, 2009 2:14 pm
by ConvertFromOldNGs
by David Mitchell >> Thu, 6 May 1999 5:13:34 GMT
What type areyou talking about for i? I'm meaning i as an Integer. How is i:=321; cool?
Re: Integer <> Character Casts
Posted: Fri Aug 07, 2009 2:14 pm
by ConvertFromOldNGs
by Kevin Alcock >> Thu, 6 May 1999 21:52:21 GMT
vars
i : Integer;begin
i := 321;
write i.Character;
end;
result is...
A
Re: Integer <> Character Casts
Posted: Fri Aug 07, 2009 2:14 pm
by ConvertFromOldNGs
by Robert Barr >> Fri, 7 May 1999 4:00:47 GMT
write 577.Character; // result is...A - double cool
write 629057.Character; // result is...A - positively chilly
(ANSI only)
Re: Integer <> Character Casts
Posted: Fri Aug 07, 2009 2:14 pm
by ConvertFromOldNGs
by John Porter >> Fri, 26 Nov 1999 3:55:24 GMT
Now for something that is actually useful...
vars
chr:Character;begin
chr:="A";
write (chr.Integer+1).Character;
end;
..... and the result is
B
Can be used for selecting the next letter: "fileA", "fileB"...
Cheers,
John P