Lasso Soft Inc. > Home

[every]

Linkevery
AuthorKe Carlton
CategoryAction
Version9.x
LicensePublic Domain
Posted25 Jul 2013
Updated25 Jul 2013
More by this author...

Description

Restricts code from executing more frequently than the specified number of seconds. Returns the number of seconds to wait until blocks should be executed.

Sample Usage

define my_thread => thread {
   public active_tick => every(60) => {
      // do stuff
   }
}

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define every(seconds::integer) => {
	local(
		gb =  givenblock,
		v = '_poll_'+#gb->self->type + #gb->methodname,
		last = var(#v),
		since = #last ? #last->secondsBetween(date) | #seconds
	)   
	if(#since >= #seconds) => {
		handle => { var(#v) = date }
		return #gb() || #seconds
	else
		return (#seconds - #since)
	}
}

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft