Results 1 to 10 of 10

Thread: adding a log at the end of script

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default adding a log at the end of script

    hello,
    i want to add a log of what the bot did at the end of the script, what type of variable would i have to store this in?

  2. #2
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    Like how many times it banked or....?
    example
    opening bank
    withdrawing
    closing

    of course it would have a timestamp

  4. #4
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Simba Code:
    AddOnTerminate('ProgressReport');
    if you're trying to record the debug of certain actions, record them in a variable, then call a procedure that prints them to console (i.e. like ProgressReport).
    I think you mean the above?
    I know some people like to make a separate procedure for a ``FinalReport,'' but I think they're one in the same.
    -Lj

  5. #5
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    Simba Code:
    AddOnTerminate('ProgressReport');
    I think you mean the above?
    I know some people like to make a separate procedure for a ``FinalReport,'' but I think they're one in the same.
    -Lj


    i already have that but i dont know how to make it print like a log of what the bot did

    Ok now I'm on my computer so I can elaborate:

    There would be a procedure like when it banks I would call

    Simba Code:
    AddReport('Banking')

    And when the user clicks stop script a log is printed on the writeln of everything the bot did like:

    Code:
    withdrawing
    banking
    fletching
    waiting
    waiting
    fletching
    waiting
    banking
    withdrawing

  6. #6
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Well I guess you could just add a debug procedure which prints the status to the debug box. In my script the output is something like:

    We are taking a break in 0h 56m 32s
    We have Oak Logs in our inventory
    We are currently walking to the Sawmill (using SPS)
    We found Planker Object DTM, walking there now
    Walked to planker using ObjDTM
    Searching for the Planker using TPAFinderPlanker
    We found the Planker with TPAFinderPlanker
    Waiting for the plank interface
    We found the plank interface
    We have Oak Planks in our inventory
    We are currently walking to the Bank (using SPS)
    Failed to find Bank Object DTM, finding symbol
    Found Bank symbol, walking there now
    Searching for the Banker using OpenBankNPCEx
    Searching for the Banker using OpenBankFast
    Found Banker using OpenBankFast
    Depositing planks
    Withdrawing logs
    We have Oak Logs in our inventory
    Potentially engaging in AntiBan
    We are currently walking to the Sawmill (using SPS)
    You could just add + TimeRunning if you want the time-stamp. I think this is what you mean. If you wanted to actually get the number of times each action was performed then you would have to assign each to a variable and increase it by 1 each time it was performed.

  7. #7
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    Well I guess you could just add a debug procedure which prints the status to the debug box. In my script the output is something like:



    You could just add + TimeRunning if you want the time-stamp. I think this is what you mean. If you wanted to actually get the number of times each action was performed then you would have to assign each to a variable and increase it by 1 each time it was performed.
    I don't want to do that as the script is running because it ruins the progress report :s I want it to print everything at the end, maybe to a file perhaps so users can show me it so I can find bugs better

    EDIT: Sort of answered my question here:

    Simba Code:
    Program Hi;
    Procedure AddReport(Report:TStringArray);
    Begin
      Writeln('' + ToStr(Report))
    End;
    Begin
      AddReport(['Banking']);
      AddReport(['Withdrawing']);
      AddReport(['Withdrawing']);
    End.

    But how do I make it Writethe timestamp like I can with writeln

    Simba Code:
    SetScriptProp(SP_WriteTimeStamp, [True]);

  8. #8
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Are you actually trying to save a file log of the script's action's during runtime?
    see SRLlog.simba (/includes/srl/core/)

  9. #9
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Simba Code:
    const
    DEBUG = True; //let the user set this.

    procedure Debugln(s:String);
    begin
      if DEBUG then
       writeLn(s);
    end;

  10. #10
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Actually nevermind after testing it it is only saving 1 string at a time

    Simba Code:
    Program Hi;
    Var
      GlobalReport:String;
    Procedure WriteReport;
    Begin
      Writeln('' + GlobalReport)
    End;
    Procedure AddReport(Report:TStringArray);
    Begin
      GlobalReport := ToStr(Report);
     // Writeln('' + ToStr(Report))
    End;
    Begin
      SetScriptProp(SP_WriteTimeStamp, [True]);
      AddReport(['Banking']);
      wait(1000)
      AddReport(['Withdrawing']);
      wait(1000)
      AddReport(['Withdrawing']);
      wait(1000)
      WriteReport;
    End.


    EDIT:

    I think I got it:

    Simba Code:
    Program TestSave;
    function OpenReportFile(): integer;
    var
      fileName,Bot_SavePath: string;
    begin

      Bot_SavePath := 'C:/Simba/'
      if (not directoryExists(Bot_SavePath)) then
        forceDirectories(Bot_SavePath);

      // make sure it's a valid file name (Windows)
      fileName := 'Fletcher Log.txt';
     // fileName := replace(fileName, '/', '-');
      //fileName := replace(fileName, ':', ' ');
      fileName := Bot_SavePath + fileName;

      try
        if (fileExists(fileName)) then
          result := appendFile(fileName)
        else
          result := createFile(fileName);
      except
        writeln('OpenSRLLogFile: '+exceptionToString(exceptionType, exceptionParam));
      end;
    end;
    procedure AddToReport(s: string);
    var
      tmpFile: integer;
    begin
      writeln(s);

      tmpFile := OpenReportFile();

      if (tmpFile >= 0) then
        try
         writeFileString(tmpFile,s);
         // writeFileString(tmpFile, '['+msToTime(getTimeRunning(), TIME_BARE)+']: '+s+#13+#10);
        except
          Writeln('Error writing File');
        finally
          closeFile(tmpFile);
        end;
    end;
    Begin
      AddToReport('Hello')
    End.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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