Em 19/08/2010 17:26, bobby escreveu:
Hi,
I have a function for increasing HEX values, based on string
manipulations, not on conversion to integer and back.
Would that be of any help?
bobby
Hi bobby,
Would you show me the function?
Here's one I received from a friend here in Brazil:
[code]
{$J+}
const
CIncStrChars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
{$J-}
function IncStr(const AString: string): string;
var
VCurrChar: PChar;
I, VPos, VBackIndex: Integer;
begin
Result := Copy(AString, 1, Length(AString));
for I := 1 to Length(AString) do
if Pos(AString[I], CIncStrChars) < 1 then
raise Exception.Create('String contains an invalid character');
if Length(AString) < 1 then
begin
Result := CIncStrChars[1];
Exit;
end;
if Length(AString) < 2 then
begin
Result := Succ(AString[1]);
Exit;
end;
VBackIndex := 0;
while True do
begin
VCurrChar := @Result[Length(Result) - VBackIndex];
VPos := Pos(VCurrChar^, CIncStrChars);
if VPos = Length(CIncStrChars) then
begin
VCurrChar^ := CIncStrChars[1];
if (Length(Result) - VBackIndex) <= 1 then
begin
Result := CIncStrChars[2] + Result;
Break;
end
else
begin
Inc(VBackIndex);
Continue;
end;
end
else
begin
VCurrChar^ := CIncStrChars[VPos + 1];
Break;
end;
end;
end;
Author: http://code.google.com/u/kingbizugo/
[/code]
I'm seeing with him to creating the DecStr function.
Thanks bobby. :) (and sorry for my english :p ).
Silvio Clécio
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus