Matthew Ellen .co .uk

Useful code snippets

StrToCol

function StrToCol(input: string):string;
var
x: integer;
i: integer;
const
bytesPerColour = 3;
begin
result := '';
if Length(input) < bytesPerColour then x := Length(input) else x := bytesPerColour;
for i := 1 to x do
begin
result := result + IntToHex(ord(input[i]), 2);
end;
while length(result) < bytesPerColour * 2 do
begin
result := result + '00';
end;
end;

Back to the top

Back to code snippets