Description

In a one-dimensional array, sets the elements in a specified index range to a value. Useful for initializing an array after a call to ArrayNew.

Returns

True, on successful completion.

Category

Array functions

Function syntax

ArraySet(array, start_pos, end_pos, value)

See also

ArrayNewPopulating arrays with data in the Developing ColdFusion Applications

History

ColdFusion MX: Changed behavior: This function can be used on XML objects.

Parameters

Parameter

Description

array

Name of an array.

start_pos

Starting index position of range to set.

end_pos

Ending index position of range to set. If this value is greater than array length, ColdFusion adds elements to array.

value

Value to which to set each element in the range.

Example

<h3>ArraySet Example</h3>

<!--- Create an array. --->
<cfset MyNewArray = ArrayNew(1)>
<!--- ArrayToList does not function properly if the Array has not been initialized
with ArraySet. --->
<cfset temp = ArraySet(MyNewArray, 1,6, "Initial Value")>

<!--- Set some elements. --->
<cfset MyNewArray[1] = "Sample Value">
<cfset MyNewArray[3] = "43">
<cfset MyNewArray[6] = "Another Value">
...

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy