List of Nasal extension functions: Difference between revisions

Jump to navigation Jump to search
maketimer
m (Link to special directory articles)
(maketimer)
Line 142: Line 142:


[[Nasal scripting language#settimer loops|More information about best practices for using the settimer function to create loops in Nasal is elsewhere on this page.]]
[[Nasal scripting language#settimer loops|More information about best practices for using the settimer function to create loops in Nasal is elsewhere on this page.]]
=== <tt>maketimer()</tt> (v. 2.11+) ===
<syntaxhighlight lang="php">
var timer = maketimer(<interval>, <function>)
var timer = maketimer(<interval>, <self>, <function>)
</syntaxhighlight>
<syntaxhighlight lang="php">
timer.start()
timer.stop()
timer.restart(<interval>)
timer.singleShot [read/write]
timer.isRunning [read-only]
</syntaxhighlight>
<syntaxhighlight lang="php">
# create timer with 1 second interval
var timer = maketimer(1.0, func { print('timer called'); });
# start the timer (with 1 second inverval)
timer.start();
# restart timer with 4 second interval
timer.restart(4);
# fire one single time in 6 seconds
timer.singleShot = 1;
timer.restart(6);
</syntaxhighlight>
<syntaxhighlight lang="php">
var Tooltip = {
  new: func
  {
    var m = {
      parents: [Tooltip]
    }
    m._hideTimer = maketimer(1.0, m, Tooltip._hideTimeout);
    m._hideTimer.singleShot = 1;
    return m;
  },
  run: func
  {
    if( !me._hideTimer.isRunning )
      me._hideTimer.start();
  }
  _hideTimeout: func
  {
    print('_hideTimeout');
  }
};
</syntaxhighlight>


=== <tt>systime()</tt> ===
=== <tt>systime()</tt> ===
166

edits

Navigation menu