Lasso Soft Inc. > Home

[lp_array_roundrobin]

Linklp_array_roundrobin
AuthorBil Corry
CategoryArray
Version8.x
LicensePublic Domain
Posted19 Apr 2006
Updated28 Apr 2006
More by this author...

Description

WARNING: This tag only works with LP8.5!  It will crash LP8.1!

Given an array, it will return the next element in the array.  Can optionally specify the index number using  ->setindex:

lp_array_roundrobin->(setindex: $indexnumber);

Requires [lp_logical_between]

Sample Usage

	var:'test' = lp_array_roundrobin;
	$test->(insert: 'a');
	$test->(insert: 'b');
	$test->(insert: 'c');
	loop: 10;
		loop_count; ': ' $test '
'; /loop; '
'; var:'test' = (lp_array_roundrobin: 1, 2, 3, 4, 5); $test->(setindex: 5); loop: 10; loop_count; ': ' $test '
'; /loop;

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_type:'lp_array_roundrobin','array',
	-description='Given an array, it will return the next element in the array.  Can optionally specify the index number.',
	-prototype;

	local:'index' = integer;

	define_tag:'onConvert';
		self->'index' += 1;
		if: self->'index' > self->size;
			self->'index' = 1;
		/if;
		return: self->(get: self->'index');
	/define_tag;

	define_tag:'setIndex',
		-required='index', -copy;
		#index = (integer: #index);
		fail_if: !(lp_logical_between: #index, 1, self->size), -1, 'Invalid index value.';
		self->'index' = #index - 1;
	/define_tag;

/define_type;

]

Related Tags

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