Results 1 to 7 of 7

Thread: Run a procedure outside of whatever is being ran...

  1. #1
    Join Date
    Aug 2007
    Location
    Santa Fe, Argentina
    Posts
    35
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default Run a procedure outside of whatever is being ran...

    Very hard to explain and likely not possible.. However it's worth a shot.

    Is a way to run a procedure, say, every 10 seconds, and have it run universally regardless of where the script is currently running?

    Hope that was understandable. I seem to remember finding a tutorial that explained a 'pseudo' method for this, however I haven't been able to find it. Currently I am simply calling the procedure in every single procedure/function that will be used, but it's getting rather tedious to manage.

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

    Default

    Are you talking about multithreading? Simba can't do this :s

  3. #3
    Join Date
    Aug 2007
    Location
    Santa Fe, Argentina
    Posts
    35
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by Officer Barbrady View Post
    Are you talking about multithreading? Simba can't do this :s
    Yes multithreading sounds like the right term... bummer!

  4. #4
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    While... do
    Not totally sure if thats what you are looking for
    You have permission to steal anything I've ever made...

  5. #5
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    You could use the TTimer component, however Windows gives that a very low priority when sending messages to applications and vice versa.

    Simba Code:
    program new;

    var
      Timer: TTimer;
      Params: TVariantArray; // Useless, but required...

    procedure OnTimer(Sender: TObject);
    begin
      // Procedure to repeat every ten seconds here...
    end;

    procedure InitialiseTimer;
    begin
      Timer := TTimer.Create(nil);
      Timer.Interval := 10000; // Every ten seconds.
      Timer.OnTimer := @OnTimer;
      Timer.Enabled := True;
    end;

    begin
      ThreadSafeCall('InitialiseTimer', Params);

      repeat
        Sleep(1000);
      Until(False);

      Timer.Free;
    end.

    However, it runs on the main-thread, and Simba for some silly reason unbinds the Writeln called from within PascalScript to the native one which prints text to the console, and not the debug box. Apart from that, it should be okay.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  6. #6
    Join Date
    Aug 2007
    Location
    Santa Fe, Argentina
    Posts
    35
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    You could use the TTimer component, however Windows gives that a very low priority when sending messages to applications and vice versa.

    Simba Code:
    program new;

    var
      Timer: TTimer;
      Params: TVariantArray; // Useless, but required...

    procedure OnTimer(Sender: TObject);
    begin
      // Procedure to repeat every ten seconds here...
    end;

    procedure InitialiseTimer;
    begin
      Timer := TTimer.Create(nil);
      Timer.Interval := 10000; // Every ten seconds.
      Timer.OnTimer := @OnTimer;
      Timer.Enabled := True;
    end;

    begin
      ThreadSafeCall('InitialiseTimer', Params);

      repeat
        Sleep(1000);
      Until(False);

      Timer.Free;
    end.

    However, it runs on the main-thread, and Simba for some silly reason unbinds the Writeln called from within PascalScript to the native one which prints text to the console, and not the debug box. Apart from that, it should be okay.
    Ah yes! This is what I found before. Found it again just now thanks to you: http://villavu.com/forum/showthread.php?t=51578

    Thanks

  7. #7
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    You could use the TTimer component
    has this been fixed now as last i heard this was broken since scar still correct? or is this now working under lape?

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
  •