API: Num
Filename:
fwpNum_intArray.ctag
Released With:
5.0.0
Current Version:
1.0.0
Status: Active
Min Lasso Tested: 8.1.0
Max Lasso Tested: 8.5.3
Related:
Still don't get it?
Check out the talk list archives, or join and ask your questions.
Documentation Error or Request?
Email documentation corrections or comments
Creates an array of integers spanning the input parameters. Particularly useful for generating year values relative to the current date when presenting popup lists for date selection.
{code=fwpNum_intArray:
-first = integer,
-last = integer,
-origin = integer or 'year',
-inc = integer;
-first - optional : any integer value defining the start of the integer array. If not specified, the value is assumed to be zero. If the -origin option is specified then this value will be added to the value of -origin to determine the starting value of the array. To make the starting value less than the value of -origin, define -first as negative.
-last - optional : any integer value defining the end of the integer array. If not specified, the value is assumed to be zero. If the -origin option is specified then this value will be added to the value of -origin to determine the final value of the array.
-origin - optional : an integer value for the start of the integer array, or use the literal 'year' or 'years' to have the origin be the 4 digit value of the current year.
-inc - optional : any integer value specifying the incremental value change between each array member. If undefined, it is assumed to be 1.
[fwpNum_intArray: -first=5, -last=-5]
Result: 5 4 3 2 1 0 -1 -2 -3 -4 -5
[fwpNum_intArray: -origin=10, -first=3, -last=-3]
Result: 13 12 11 10 9 8 7
[fwpNum_intArray: -origin='year', -first=-3, -last=3]
Result: 2000 2001 2002 2003 2004 2005 2006
[fwpNum_intArray: -first=6]
Result: 6 5 4 3 2 1 0
[fwpNum_intArray: -first=10, -inc=2]
Result: 10 8 6 4 2 0
<?lassoscript
//............................................................................
//
// pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*
{fileName= fwpNum_intArray.ctag }
{rsrcType= tag }
{rsrcName= fwpNum_intArray }
{rsrcHTTP= www.pageblocks.org/refc/fwpNum_intArray }
{lassoVrsnMin= 8.1.0 }
{lassoVrsnMax= 8.5.3 }
{author= Greg Willits }
{authorEmail= subscribe to pbTalk at www.pageblocks.org/talk/ }
{authorHTTP= www.pageblocks.org }
{desc= Creates absolute and relative arrays of numbers. }
{maintvsrn= 1.0 }
{maintrelease= 5.0.0 }
{maintdate= 2006-01-16 }
{maintauthor= Greg Willits }
{maintnotes= initial release }
*/
//.............................................................................
//
// -first = first number in the array
// -last = last number in the array
// -origin = numeric origin for relative arrays
// = use string 'year' to set origin as the current YYYY value
// -inc = increment step between each value
//
// ............................................................................
define_tag:'fwpNum_intArray',
-priority='replace',
-optional='origin',
-optional='first',
-optional='last',
-optional='inc';
local:
'rArray' = (array),
'fw_origin' = local:'origin',
'fw_first' = local:'first',
'fw_last' = local:'last',
'fw_inc' = local:'inc';
if: !(local:'fw_first');
#fw_first = 0;
/if;
if: !(local:'fw_last');
#fw_last = 0;
/if;
if: !(local:'fw_inc');
#fw_inc = 1;
else;
#fw_inc = math_abs:#fw_inc;
/if;
if: !(local:'fw_origin');
#fw_origin = '';
/if;
if: (#fw_origin >> 'year') || (((params->find:'-year')->size) > 0);
#fw_origin = (date)->year;
/if;
#fw_origin = integer:#fw_origin;
#fw_first += #fw_origin;
#fw_last += #fw_origin;
if: #fw_first > #fw_last;
#fw_inc = (-1) * #fw_inc;
/if;
loop:
-from = #fw_first,
-to = #fw_last,
-by = #fw_inc;
#rArray->(insert: loop_count);
/loop;
return:#rArray;
/define_tag;
?>
© 2002-2012, pageblocks.org