Link | lp_array_roundrobin |
Author | Bil Corry |
Category | Array |
Version | 8.x |
License | Public Domain |
Posted | 19 Apr 2006 |
Updated | 28 Apr 2006 |
More by this author... |
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]
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;
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; ]
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft