Lasso Soft Inc. > Home

[Array->Insert]

[Array->Insert] inserts a value into the array. Accepts a single parameter which is the value to be inserted and an optional integer parameter identifying the index of the location where the value should be inserted. Defaults to inserting the parameter at the end of the array. Returns no value.

The first element in an array is at index 1.

Note: This tag will not replace an item in the array. Instead, it will insert the new item and increment the index of all the existing items that follow.

  • Syntax
  • Parameters
[Array->(Insert: 'Insert Value')]

[Array->(Insert: 'Insert Value', Array Index)]
Required Parameters
Array The array into which the value should be inserted.
Insert Value The value which should be inserted as the last element of the array.
Examples

To insert a new element into an array:

Use the [Array->Insert] tag. The following example starts with a partial array of the days of the week, then inserts 'Sun' as the first element and 'Sat' as the last element of the array.

<?LassoScript
  Variable: 'DaysOfWeek'=(Array:'Mon','Tue','Wed','Thu','Fri');
  $DaysOfWeek->(Insert: 'Sun', 1);
  $DaysOfWeek->(Insert: 'Sat');
  Output: $DaysOfWeek;
?>
Result:
(Array: (Sun), (Mon), (Tue), (Wed), (Thu), (Fri), (Sat))
Tag Link [Array->Insert] Category Array
Type Member Data Source Any
Support Preferred Version 5.0
Output Type None Security None
Implementation Internal Sets Lasso 6.0, Lasso 5.0

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

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