ArraySet Context

[arrayset name=…&dim=…]<WebDNA that resolves to array element assignments>[/arrayset]

The array context will allow the WebDNA programmer to create an array data object with up to five dimensions.


· Name - The variable name you specify to represent the array object.

· Dim - Comma delimited series of numbers representing the array dimension sizes, i.e. '3,3,3', which would represent a 3x3x3 dimensioned array.

To create a three-dimensional array, insert a [arrayset] context into a template.

For example:

[arrayset name=myarray&dim=2,2,2]

This creates an array, called 'myarray', that will persist for the duration of the template. Note that the 'index=value' pairs within the [arrayset] tags are optional when creating a new array. Array indices can be assigned at any time.

When the 'dim' parameter is supplied with the arrayset context, it implies that this will be a new array object. Subsequent calls to arrayset, using the same variable name (and without using the ‘dim’ parameter, imply new index assignments to an existing array object.

So after we have created the 'myarray' object using the line shown above, we can assign index value at a later time using:

[arrayset name=myarray](2,2,2)=xxx&(2,2,2)=zzz[/arrayset]

Once you have created an array, you can access the 'elements' of the array using the following methods:

Use the [ArrayGet] context to retrieve one or more array elements at once, or....

Use a 'global tag' reference to retrieve a single array element. Here is the syntax for the global method:


So, for example, given the following array definition...

[arrayset name=DOW&dim=7](1)=Sun&(2)=Mon&(3)=Tue&(4)=Wed&(5)=Thu&(6)=Fri&(7)=Sat[/arrayset]

...the tag '[DOW(7)]' would resolve to 'Sat'

User Contributed Notes

Copyright © 2008 WebDNA Software Corporation, Inc.