SRL Archive - SRL Snippets

IntToASCII[other funny func]


CynicRus

2013-01-22 02:37:03

Hi. This is other funny function:


program new;

function IntToASCII(Value: Integer; Digits: Integer): string;
var
I: Integer;
begin
Result := '';
I := 0;
while I < Digits do
begin
Result := Result + Chr(Value and $FF);
Value := Value shr 8;
Inc(I);
end;
end;

begin
WriteLn(InttoASCII(12,1));
end.

Backward conversion:


function ASCIIToInt(S: string; Digits: Integer): Integer;
var
I: Integer;
begin
Result := 0;
I := Min(Length(S), Digits);
while I > 0 do
begin
Result := Result shl 8;
Result := Ord(S[I]) + Result;
Dec(I);
end;
end;

Output:

Mr[S]

2013-01-22 03:06:37

Gender icons :o

kyleinkman

2013-01-22 08:13:08

lol neat, your one from yesterday is still my favorite though :P