1 (edited by cbnbg 2019-12-31 07:55:52)

Topic: [Script] Create GUID

You can validate GUIDs here:
http://guid.us/Test/GUID

function RightStr(txt: string; len: integer): string;
begin
  if Length(txt) > len then
    result := copy(txt, Length(txt)-(len - 1), len)
  else
    result := txt;
end;
function CreateGUID: string;

var
  ticks: integer;

begin
  ticks := Gettickcount;

  Randomize;

  result := IntToHex(StrToInt(RightStr(IntToStr(ticks),6)),6);
  result := result + IntToHex(StrToInt(RightStr(IntToStr(ticks div 1000),6)),6);

  while Length(result) < 32 do
  begin
    result := result + IntToHex(Random(16),2);
  end;

  result := Copy(result, 1, 8) + '-' +
            Copy(result, 9, 4) + '-' +
            Copy(result, 14, 4) + '-' +
            Copy(result, 19, 4) + '-' +
            Copy(result, 20, 12);

end;