Lesson 8. Working in Depth with Variables

I l @ ve RuBoard

Lesson 8. Working in Depth with Variables

As you have already learned, variables are one of the most important aspects of making Web content dynamic. So far, you have worked with simple variables, such as a variable to hold a person's first name , or the current date. But in ColdFusion, and most other programming languages, you have several complex variable types available to you. These variables hold more information and are organized differently.

List variables are actually simple variables like the ones you have used before. The only difference is that a list variable holds multiple values that are separated by a delimiter. A delimiter can be any character; most commonly, it's a comma. The delimiter must remain the same throughout the list of values. For example, a list variable for states, using the default comma delimiter , would look like this: IA,IN,MI,MN,NY. You worked with a list variable in Lesson 7 with the check box values.

Structures are very powerful ways to store related collections of information.

Arrays are a more complex type of variable. They are referenced by a single name, but can contain many different values. You might create an array to hold items in a shopping cart or to hold all of a user's information. Values in an array are assigned and referenced by position. So in an array of a user's information, the first position might be the user's name, the second position might be their street address, and so on. If you wanted to access the user 's name, you would specify the first position in the array.

Structures are very similar to arrays in that one structure holds multiple values. The big difference is how they are referenced: rather than being referenced by position, structures use keys. Using the example above with a structure, you would reference the key names , which might be Name, Address, and so on.

WHAT YOU WILL LEARN

In this lesson you will:

  • Learn about alternative variable types in ColdFusion

  • Use a list variable

  • Store items in an array

  • Access items in an array

  • Examine the use of structures

  • Learn how to pass a structure to another template

APPROXIMATE TIME

This lesson will take approximately 1 hour and 15 minutes to complete.

LESSON FILES

Starting Files:

Lesson8\Start\basicform.cfm

Lesson8\Start\formprocess.cfm

Completed Files:

Lesson8\Complete\basicform.cfm

Lesson8\Complete\formprocess.cfm

I l @ ve RuBoard


Macromedia ColdFusion 5. Training from the Source
Macromedia ColdFusion 5 Training from the Source (With CD-ROM)
ISBN: 0201758474
EAN: 2147483647
Year: 2002
Pages: 99
Authors: Kevin Schmidt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net