42 CHAPTER 30 Extending ColdFusion with CFX
Listing 30.8 (continued)
<br>
Standard Deviation:
<strong>#NumberFormat(MerchStats.StandardDeviation, “,0.00”)#</strong>
<br>
</cfoutput>
</body>
</html>
An Important Warning
If this all sounds too good to be true, it is—kind of. This whole strategy will fail if there is there is
already a variable called
FilmsStats in the calling ColdFusion page and that variable is anything
other than a structure. In such a case, ColdFusion will crash if a C++ CFX attempts to reference the
variable as a structure. With a Java CFX, the program won’t crash, but the tag will still throw an
error. To protect yourself against such a possibility, you could use a line like one of the following,
just before calling the CFX tag each time.
This line simply deletes the
FilmsStats variable if it exists already (if it doesn’t exist, nothing hap-
pens, so this line does no harm):
<cfset StructDelete(VARIABLES, “FilmsStats”)>
Alternatively, this line creates a new, empty FilmsStats structure (regardless of whether it already
exists):
<cfset FilmsStats = StructNew()>
Figure 30.12
CFX tags can
return multifaceted
information to
ColdFusion.
Commentaires sur ces manuels