Results 1 to 8 of 8

Thread: Clear running time?

  1. #1
    Join Date
    Jul 2008
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Clear running time?

    How do I Start the running time and clear it? Right now I got a program with a button that starts and stops the macro. When you stop it it produces a report with the amount of potions used and food eaten. It also tells how much time past. How do I get it so the time starts when I click the start button, and stops/clears when I click the stop button?

    Code:
    procedure StartMacro(Sender: TObject);
    begin
    if MacroIsLive = False then
    begin
    MacroIsLive := True;
    MacroIsLiveButton.Caption := 'End Macro';
    end else if MacroIsLive = True then
    begin
    MacroIsLive := False;
    MacroIsLiveButton.Caption := 'Start Macro';
    ConvertTime(GetTimeRunning, H, M, S);
    RunningTime := (IntToStr(H) + ':' + IntToStr(M) + ':' + IntToStr(S));
    DebugBox.Lines.Add('{          Macro Report        }');
    DebugBox.Lines.Add('Health Potted: ' + IntToStr(HealthPotionsUsed) + '.');
    DebugBox.Lines.Add('Mana Potted: ' + IntToStr(ManaPotionsUsed) + '.');
    DebugBox.Lines.Add('Food Eaten: ' + IntToStr(Food1Eaten) + '.');
    DebugBox.Lines.Add('Time Ran: ' + RunningTime + '.');
    DebugBox.Lines.Add('');
    end;
    end;

  2. #2
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    MarkTime(); and TimeFromMark();?

  3. #3
    Join Date
    Jul 2008
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I found a new way. I just used GetSystem time on the beginning and ending of the macro and subtracted them. Then I could find the running time.

    Code:
    procedure StartMacro(Sender: TObject);
    begin
    if MacroIsLive = False then
    begin
    StartTime := GetSystemTime;
    MacroIsLive := True;
    MacroIsLiveButton.Caption := 'End Macro';
    end else if MacroIsLive = True then
    begin
    MacroIsLive := False;
    MacroIsLiveButton.Caption := 'Start Macro';
    EndTime := GetSystemTime;
    MergeTime := EndTime - StartTime;
    ConvertTime(MergeTime, H, M, S);
    RunningTime := (IntToStr(H) + ':' + IntToStr(M) + ':' + IntToStr(S));
    DebugBox.Lines.Add('{          Macro Report        }');
    DebugBox.Lines.Add('Health Potted: ' + IntToStr(HealthPotionsUsed) + '.');
    DebugBox.Lines.Add('Mana Potted: ' + IntToStr(ManaPotionsUsed) + '.');
    DebugBox.Lines.Add('Food Eaten: ' + IntToStr(Food1Eaten) + '.');
    DebugBox.Lines.Add('Time Ran: ' + RunningTime + '.');
    DebugBox.Lines.Add('');
    end;
    end;
    Edit: To _99
    sorry I posted at the same time. I think that is an SRL include function so I haven't seen it. That's ok though, I got a way. Thanks

  4. #4
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Also GetSystemTime; starts at run of a script.
    ~Hermen

  5. #5
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    as Hermpie said, it starts right when you press run.. so it's not entirely accurate for what you're doing..

  6. #6
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yes it is. at the start of his procedure he would go,

    SCAR Code:
    S := GetsystemTime;

    remembering that S is an integer of course.

    at the end of the procedure he would then write

    SCAR Code:
    WriteLn('Took: '+IntToStr(GetSystemTime-S)+' ms');

    giving him the precise time to the milisecond. edit: Like he did in his script (just looked at it )
    “Ignorance, the root and the stem of every evil.”

  7. #7
    Join Date
    Mar 2009
    Location
    Ireland
    Posts
    111
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    but if he, as he said, has a form with a button to stop/start the bot, it would be easier to use MarkTime(), and TimeFrom Mark().

    Just my personal preference.

  8. #8
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    MarkTime() and TimeFromMark do the same as Blumblebee's example
    lol

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
  •