Skip to main content
Known Participant
April 8, 2008
Question

Structure Help

  • April 8, 2008
  • 2 replies
  • 305 views
There are 2 things that I'm not sure how to write with structure in CF:
First: I'm calling a function and passing the whole struncture (it does not expect a return value)
Here is how I wrote the code and I got error:

<CFSET BuildMyLetter=BuildLetter(stLetterType)>

Second:
Within the function, I need to do something by looping the code based on one of the structure's key, that is, total page number, such as,
if stLetterType["TotalPage"]=1 the code is looped 1 time, if stLetterType["TotalPage"]=2, the code is looped 2 times.
I wrote my loop this way and generates this error:
The value "TotalPage" cannot be converted to a number

<CFFUNCTION name="BuildLetter">
<CFARGUMENT name="stLetterType" type="Struct" required="true">

<CFLOOP collection="#stLetterType#" item=#stLetterType[TotalPage]#>

my codes here

</cfloop>

</CFFUNCTION>

Please help!
This topic has been closed for replies.

2 replies

Inspiring
April 8, 2008
Put "TotalPage" in quotes
<CFLOOP collection="#stLetterType#" item=#stLetterType["TotalPage"]#>
Inspiring
April 8, 2008
1) the correct cfargument type is 'struct', not 'structure'
2) what error did you get?
3) before doing your cfloop it may be useful to check that that
structkey exists...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/