SRL Archive - OSR Help

Logging


Death12652

2010-05-11 09:39:13

So I have a script that creates randomly generated usernames. Then uses that username to sign up. Is there a way to log those usernames into some type of file like another scar or the debug or something like that?

Awkwardsaw

2010-05-11 09:40:11

ctrl+space, Writeini :)

Death12652

2010-05-11 14:59:09

This is what I have. Made by Nava2.

function RandStr(Len: Integer): string;
var
I, cLen: Integer;
Chars: string;
begin
Chars := 'abcdefghijklmnopqrstuvwxyz0123456789';
cLen := length(chars);
for i := 1 to Len do
if (Random(2) = 1) then
Result := Result + uppercase(Chars[Random(cLen) + 1])
else
Result := Result + Chars[Random(cLen) + 1];
end;

Where do I put the WriteINI in for it to save the random characters it generates. If not then do I have to modify it?

Coh3n

2010-05-11 18:41:17

I would create a new procedure.


procedure saveToFile(str: String);
var
theFile: Integer;
tempStr: String;
begin
if (FileExists(appPath + 'fileName.txt')) then
begin
theFile := OpenFile(appPath + 'fileName.txt', false); //will open the file if it exists
ReadFileString(theFile, tempStr, FileSize(theFile)); //copies the text that's already there
CloseFile(theFile);
end;

theFile := RewriteFile(appPath + 'fileName.txt', false) //will create a new file if it doesn't already exist
WriteFileString(theFile, tempStr + str + #10); //writes what was already there + str to file ~ the #10 will go to the next line
CloseFile(theFile);
end;

var
i: Integer;
begin
for i := 1 to 10 do
saveToFile(intToStr(i));
end.
This should work like you want it to. :)

E: What this does is just write the str to a text file. An INI file works a little differently ~ check out this tutorial if you're interested in the INI functions.

Death12652

2010-05-11 23:45:00

Thanks so much you helped a lot.

Coh3n

2010-05-11 23:49:01

From: death12652
Thanks so much you helped a lot.

No problem. :)

Death12652

2010-05-12 20:22:07

Sorry I don't get how this works. It just keeps putting a FileNme.txt Which I get but All it does is put 1-10 on the first line and then does that over and over. I wanted it to put in there what my random name function put. Also it doesn't put it on a new line? just keeps putting it on the same line no spaces.

here I will show you what it looks like?

123456789101234567891012345678910

over and over and over again.

Coh3n

2010-05-12 22:16:24

From: death12652
Sorry I don't get how this works. It just keeps putting a FileNme.txt Which I get but All it does is put 1-10 on the first line and then does that over and over. I wanted it to put in there what my random name function put. Also it doesn't put it on a new line? just keeps putting it on the same line no spaces.

here I will show you what it looks like?

123456789101234567891012345678910

over and over and over again.

I just used the 1-10 as an example. I don't think it's going on a separate line because I was using linux and I'm assuming you're using Windows. Try this:


function RandStr(Len: Integer): string;
var
I, cLen: Integer;
Chars: string;
begin
Chars := 'abcdefghijklmnopqrstuvwxyz0123456789';
cLen := length(chars);
for i := 1 to Len do
if (Random(2) = 1) then
Result := Result + uppercase(Chars[Random(cLen) + 1])
else
Result := Result + Chars[Random(cLen) + 1];
end;

procedure saveToFile(str: String);
var
theFile: Integer;
tempStr: String;
begin
if (FileExists(appPath + 'fileName.txt')) then
begin
theFile := OpenFile(appPath + 'fileName.txt', false); //will open the file if it exists
ReadFileString(theFile, tempStr, FileSize(theFile)); //copies the text that's already there
CloseFile(theFile);
end;

theFile := RewriteFile(appPath + 'fileName.txt', false) //will create a new file if it doesn't already exist
WriteFileString(theFile, tempStr + str + #13); //writes what was already there + str to file ~ the #13 will go to the next line
CloseFile(theFile);
end;

begin
saveToFile(RandStr(8));
end.

Death12652

2010-05-13 00:06:15

Nevermind Its Working Perfectly!

Coh3n

2010-05-13 00:12:29

From: death12652
It Still Doesn't Save to a new line. Where are you going to get these numbers?

I just know from reading around the forums. Try having #10#13 instead of just one.

Death12652

2010-05-13 00:46:01

thanks