Results 1 to 11 of 11

Thread: Is it possible to have a reseting timer in a loop?

  1. #1
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Is it possible to have a reseting timer in a loop?

    Basically

    Code:
    procedure srl;
     var
      TIME : Integer;
     begin
      MarkTime(TIME);
       repeat
        Blah;
        Blah;
        until TimeFromMark(TIME) > 15000  then
        ClearPreviousMarktime;
       RestartProcedure;
     end;
    That's a quick example, but something like that?
    Thick As Blood

  2. #2
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    SCAR Code:
    procedure DoThis;
    var
      T: integer;
    begin
      while(....) do
      begin
        MarkTime(T);
        repeat
          //....
        until(..)
      end;
    end;

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  3. #3
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    MarkTime does the same as TIME := GetSystemTime; and TimeFromMark does (GetSystemTime - TIME) so it knows the time passed since TIME was set.
    Ce ne sont que des gueux


  4. #4
    Join Date
    Dec 2006
    Posts
    354
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    So there's no command to get the marktime to reset itself?
    Thick As Blood

  5. #5
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Thick As Blood View Post
    So there's no command to get the marktime to reset itself?
    Just reset the integer to a different time
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  6. #6
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    if ((Total[2] mod TakeBreaksEvery) = 0) then
        begin
          T := GetSystemTime;
          WriteLn(TheTime + ' Taking a break for ' + IntToStr(BreakFor) + ' minute(s)...');
          LI := LoggedIn2;
          if (LI) then
            LogOut;
          Sleep(BreakFor * 60000);
          WriteLn('Done breaking.');
          if (LI) then
            InitPlayer;
          IncEx(TimeStarted, GetSystemTime - T);
        end;

    Having two counters and adding the difference in time to the first mark will allow you to, but that is just one example of the possibilities, that one is used to not have the time you spend breaking affect the loads per hour.

  7. #7
    Join Date
    Mar 2008
    Location
    New Jersey
    Posts
    1,673
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    SCAR Code:
    procedure srl;
     var
      TIME : Integer;
     begin
      MarkTime(TIME);
       repeat
        Blah;
        Blah;
        until TimeFromMark(TIME) > 15000  then
        ClearPreviousMarktime;
       RestartProcedure;
     end;

    to

    SCAR Code:
    procedure srl;
     var
      TIME : Integer;
     begin
      MarkTime(TIME);
       repeat
        Blah;
        Blah;
        until TimeFromMark(TIME) > 15000  then
        MarkTime(Time); //reset?
       RestartProcedure;
     end;

  8. #8
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Quote Originally Posted by Thick As Blood View Post
    So there's no command to get the marktime to reset itself?
    There is no need to 'Reset' it, you can just do another MarkTime.
    Ce ne sont que des gueux


  9. #9
    Join Date
    Mar 2008
    Location
    New Jersey
    Posts
    1,673
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    Quote Originally Posted by Floor66 View Post
    There is no need to 'Reset' it, you can just do another MarkTime.
    Isn't that what I just showed? lol maybe I misunderstand something, but I'm pretty sure you just wrote out my example

  10. #10
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Yeah, u did, just splainin' some more ;P
    Ce ne sont que des gueux


  11. #11
    Join Date
    Nov 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hmm, as has been said there's a dozen ways to do it.

    I did another way for a rather simple script, basically the other way round to the above.

    Procedure 1 grabs the time and adds a bit on to mark a point in the future.

    Code:
    Stopwatch := (GetSystemTime + 60000);             //  Timer
    Procedure 2 is one of many loops but on its way this one constantly checks if the current System Time has reached the System Time +60000 that was saved earlier.
    Code:
    if GetSystemTime < Stopwatch then 
      begin
        Wait(100);                            // Staller
      end
    If Stopwatch hasn't been matched by the current System Time, it waits.

    The next time Procedure 1 comes around it resets Stopwatch to systemtime + 60000 again, Procedure 2 carries on checking if it's been reached yet... and the loops spin on.
    Last edited by Treehopper; 11-23-2009 at 01:10 AM.

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
  •