• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 13. CFScript > Working with Data Structures

Working with Data Structures

CFScript also enables the programmer to simplify the construction of complex data structures. The tag-based structure of ColdFusion can easily become very tedious for this task. Let’s say that we want to create a structure of customer billing information; we could do the following:

<cfset customer = StructNew()> 
<cfset customer.ID = FORM.CUSID> 
<cfset customer.name = StructNew()> 
<cfset  customer.name.first = FORM.FirstName> 
<cfset FSET customer.name.last = FORM.LastName> 
<cfset customer.billinginfo = StructNew()> 
<cfset customer.billinginfo.address = StructNew()> 
<cfset customer.billinginfo.address.street = FORM.street> 
<cfset customer.billinginfo.address.city = FORM.city> 
<cfset customer.billinginfo.address.state = FORM.state> 
<cfset customer.billinginfo.address.zipcode = FORM.zipcode> 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint