Results 1 to 11 of 11

Thread: Logging

  1. #1
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Logging

    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?

  2. #2
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    ctrl+space, Writeini
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  3. #3
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This is what I have. Made by Nava2.

    Code:
    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?
    Last edited by Death12652; 05-11-2010 at 08:36 PM. Reason: Help

  4. #4
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    I would create a new procedure.

    SCAR Code:
    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.
    Last edited by Coh3n; 05-11-2010 at 10:59 PM.

  5. #5
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks so much you helped a lot.

  6. #6
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by death12652 View Post
    Thanks so much you helped a lot.
    No problem.

  7. #7
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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?

    Code:
    123456789101234567891012345678910
    over and over and over again.

  8. #8
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by death12652 View Post
    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?

    Code:
    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:

    SCAR Code:
    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.

  9. #9
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nevermind Its Working Perfectly!
    Last edited by Death12652; 05-13-2010 at 04:13 AM.

  10. #10
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by death12652 View Post
    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.

  11. #11
    Join Date
    Sep 2008
    Location
    My House
    Posts
    519
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •