DML2  v1.0.1
Introduction to DML2
Getting Started
Files and Directories
Custom Tags
File Output
Creating Objects
Rendering and Scope
Object Execution
Rendering Arrays
Automatic Tags
Release Notes
<( Arrays )>

If you've programmed with arrays before, this section should be a fairly easy read. If not, be prepared for a rough ride =). Arrays are basically lists of objects of the same type. Lets say you've got an object that will contain a bunch of lines. Rather than name and define each one, it is easier to just create a bunch of objects, in other words, an array of objects. The benefits of using arrays are that you don't have to hard-code the number of elements, DML2 will just use however many of the given elements as you want. Here's how an array is defined:

Date[] arrayOfDates

This is exactly like any other definition except for the pair of brackets ([]). Now when you want to access elements within the array, you type the name, followed by the number of the object you want to access enclosed in brackets (with no spaces). Note that the numbers of the elements begin with zero. So the third element is numbered 2. This is a throwback to programming and hopefully it doesn't bother you too much. To summarize, if you type <(arrayOfDates[2])> it will access the 3rd element in the array of Date objects we defined above.

When you access an element inside of an array, it behaves just like any other object of the given type. So if you typed <(arrayOfDates[5])> inside of a property's value or an output definition, it will render the Date object.

You can also assign objects in an array to some value or other object of the same type. So if you want to copy someDate into the 2nd element of arrayOfDates, you can just type the following:

arrayOfDates[1] = someDate

If you want to add on to an array, all you have to do is assign the element of the array to some sort of value. In programming languages, you usually have to define how many objects will be in the array first. In DML2 it just adds variables as you ask for them. This is convenient, but make sure you don't accidentally type a huge number inside the brackets or DML2 will waste time addinig a ton of elements. If you didn't understand that last little bit, don't worry, it shouldn't matter =)

You can also add to an array using a special short-hand notation. Just put a hash/pound/number sign (#) in between the brackets and it will automatically add on to the end of the array. This way, if you need to add an element to the middle of the array, you don't have to renumber all the others.
©2002 Jared Krinke. ((( Revolution )))