Using ColdFusion MX Variables


A variable contains a data value. Variables are referred to by a name as defined in the program. The programming code performs the actions or operations on the data contained in the variables.

Variable are named based on the following conventions:

  • Names must begin with a letter, followed by a combination of letters, numbers, and underscores (_).

  • Variable names are not case sensitive. That is, IncomeTax, INCOMETAX, and incometax can be used to refer to the same variable.

  • The generally accepted naming rules are to capitalize the first letter of each word in the variable name.

  • Variable names cannot have spaces.

  • Reserved words in ColdFusion cannot be used as user-defined variable names. These reserved words include function names and operators.

Note

A period can be used with cookie and scope-defining variables. A query result is also a variable. Therefore, ensure that it is not the same as any other local variable.

The <CFSET> tag is used to create a variable and assign a value to it. The syntax of <CFSET> tag is as follows:

 <CFSET Variable_name=Expression> 

For example:

 <CFSET Name = "Jacob"> <CFSET x = 1> 

The variable Name is assigned the name Jacob, and the variable x is assigned the value 1.

Note

The <CFSET> tag does not have an end tag.

The datatype of the value in the variable indicates the information the variable represents, such as number, string, or date.




Macromedia ColdFusion MX. Professional Projects
ColdFusion MX Professional Projects
ISBN: 1592000126
EAN: 2147483647
Year: 2002
Pages: 200

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