Hey - as you can probably tell by the subject, I'm frustrated to no end.
I'm trying to write a new program, and one of the functions I need works
when I run it through the debugger (IE: hold down the F8 key all the way
through) but when I simply run the program, it keeps coming back with the
same result EVERY TIME. Here's the code;
Program Test;
var
i: Integer;
Function Getpassword(Length: Byte): String;
const
Letters: String[36] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
var
B: Byte;
Temp: String;
begin
Temp := '';
Randomize;
for B := 1 to Length do
{ Temp := Temp + Letters[Random(36) + 1]; }
Temp := Temp + Copy(Letters, Random(36) + 1, 1);
Getpassword := Temp;
end;
begin
for i := 1 to 10 do WriteLn(Getpassword(i + 5));
end.
as you can see, I've tried two methods for grabbing a charachter from the
'Letters' const, and they both work. When I run this program as-is, I get
the same string over and over, but since I'm using different lengths each
time it's run, the first few letters of the password remain the same, but
with a new letter/number tacked on to the end of it.
I tried various things to try to blank the 'Temp' variable within the
function itself (I actually had a few lines of code that went something
like;
Temp := '';
Temp := 'A BLANK STRING!!!!!!';
Temp[0] := #0;
Temp := ''; )
I've also tried creating a global variable - 'S' - which was a string, and
making the for loop in the main body of the code look like;
for i := 1 to 10 do
begin
S := '';
S := Getpassword(10);
WriteLn(S);
end;
but STILL got the same results.
OTOH - when I run the thing through step-by-step with the debugger, every
single one of the 10 lines contains a *COMPLETELY* different password! WHY?
(I'll bet it's one stupid little thing that I could change, and it'll make
it work properly, and I also know that when I find that stupid little
thing, I'll scream :< ).
Stewart Honsberger,
blackdeath@tinys.oix.com
... Profanity is the one language all programmers understand
-!- GOPGP v1.11
--- Squish/386 v1.11
---------------
* Origin: Blackdeath BBS - Private (1:229/604)
|