🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #179

Randomize and Random

#179
From: Eugene V. Goldberg
Date: Mon, 26 Jan 2004 11:36
41 lines
1797 bytes
I have the following functions:

function TfrmTickets.GetLogin(Prefix: String): String;
var
  i, Digit: Integer;
begin
  Result := Prefix;
  Randomize;
  for i := Length(Result) + 1 to 8 do
  begin
    Digit := Random(10);
    if Digit = 0 then
      Digit := 1;
    Result := Result + IntToStr(Digit)
  end;
end;

function TfrmTickets.GetPassword: String;
var
  i, Digit: Integer;
begin
  Randomize;
  Result := '';
  for i := 1 to 8 do
  begin
    Digit := Random(10);
    if Digit = 0 then
      Digit := 1;
    Result := Result + IntToStr(Digit)
  end;
end;

I am calling this functions one after another in a loop, 10 times.
And as the result i have login = password = somestring1 for 4 calls,
login = password = somestring2 for other 6 calls. So i have the same
strings generated several times. Whats wrong?

I need to generate different values for login and password every time.

Thanx,
Eugene.
Technical Details
Message-ID: <4014fbf5@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d30,64bfe8b17e3a4cc8,start
X-Google-Attributes: gid109d30,public
X-Google-ArrivalTime: 2004-01-26 03:39:45 PST
From: "Eugene V. Goldberg" <egold@mts-nn.ru>
Newsgroups: borland.public.delphi.language.objectpascal
Subject: Randomize and Random
Date: Mon, 26 Jan 2004 14:36:33 +0300
Lines: 43
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 213.177.102.92
Message-ID: <4014fbf5@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1075117045 213.177.102.92 (26 Jan 2004 03:37:25 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail