Results 1 to 8 of 8

Thread: is it possible to interupt a wait procedure?

  1. #1
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default is it possible to interupt a wait procedure?

    is it possible to interrupt a wait procedure? like if you have wait(10000);

    what actions can you do to automatically stop this from reaching 10000?

  2. #2
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    You can use a while do loop:

    Simba Code:
    while not(whatever) do
      wait(1000);

    That will wait indefinitely until whatever is true. Obviously you should put in failsafes and whatnot to make sure you don't get stuck in an infinite loop.

    You can use repeat until loops as well to do the same thing:

    Simba Code:
    repeat
      wait(1000);
    until(whatever);

    Just remember that failsafes are necessary when using loops like these.

  3. #3
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    No, you'll have to use loops like the above. I would recommend the while loop.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  4. #4
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It depends on what procedure you are doing. So what are you doing?

    I'd recommend making a function then use WaitFunc, I personally think its more efficient.

  5. #5
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    even if you do jam it in a loop it still is actively counting to the number specified...

    i dont think there is a way...

    i tried

    Simba Code:
    program new;


     var
     x:integer;
    begin
    ClearDebug
    while x=0 do
    begin
    if iskeydown(16) then
    break;
    wait(10000);
    if iskeydown(16) then
    break;
    end;
    writeln('ggf')
    end.



    even by jamming a break loop trigger before and after the wait(); still nothing...


    there should be a stopwait func...

  6. #6
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Simba Code:
    var
       SomeCondition: Boolean;



    Function WaitSomething(TimeToWait: Integer):  Boolean;
    var
      T: integer;
    begin
      Result:= False;
      T := (GetSystemTime + TimeToWait);
      while (GetSystemTime < t) do
      begin
        if (SomeCondition) then
        begin
          Result:= True;
          Break;
        end;
        Wait(50);
      end;
    end;


    The above will wait until SomeCondition is set to true.. if False, it will keep repeating some procedure/function until it times out OR until somecondition which can make it break out.

    The problem would be setting somecondition. See you have to set it before running the function.. OR set it during the function in the while loop.
    I am Ggzz..
    Hackintosher

  7. #7
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thats why I said it depends on what you are doing. WaitFunc is probably the best function I know as of now. It checks for the function every X time until the final time is reached. So

    if waitfunc(@16keyisdown, 100, 10000) then
    Exit;

    It wait until the function is true, then break out of the wait.

  8. #8
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by wantonman View Post
    even if you do jam it in a loop it still is actively counting to the number specified...

    i dont think there is a way...

    i tried

    Simba Code:
    program new;


     var
     x:integer;
    begin
    ClearDebug
    while x=0 do
    begin
    if iskeydown(16) then
    break;
    wait(10000);
    if iskeydown(16) then
    break;
    end;
    writeln('ggf')
    end.



    even by jamming a break loop trigger before and after the wait(); still nothing...


    there should be a stopwait func...
    Obviously you'll use a smaller wait not 10 seconds..
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

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
  •