Have you output restList to see what is in it?
In your example - <reportID>111,112,207</reportID> this is what I would
expect to see from your code:
repIDStart = 1
repIDEnd = 33 (22 + 11)
repIDTotal = 32
restList = <reportID>111,112,207</reportID
Try this:
repIDStart = #Find("<reportID>", content, 1)# + 10;
repIDEnd = #Find("</reportID>", content, repIDStart)#;
repIDTotal = (repIDEnd)-(repIDStart);
restList = #Mid(content, repIDStart, repIDTotal)#;
Dan
-----Original Message-----
From: JoshMEagle [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 14, 2000 2:29 PM
To: CF-Talk
Subject: List [Array] and Val(troubles) -> HELP!
I have a dilemma, any help is deeply appreciated. I've been driving myself
nuts trying to figure out why this doesn't work.
The variable restList comes from an XML file I'm parsing and contains 3
comma delimited numbers:
<reportID>111,112,207</reportID> (or any infinite variation of numbers in
comma delimited format)
I do the following to pull the list from the XML line:
<cfscript>
repIDStart = #Find("<reportID>", content, 1)#;
repIDEnd = #Find("</reportID>", content, repIDStart)#+11;
repIDTotal = (repIDEnd)-(repIDStart);
restList = #Mid(content, repIDStart, repIDTotal)#;
</cfscript>
I run the following loop to take each list item, convert it to a number and
pass it to a custom tag for processing in an SQL statement that then outputs
the report associated with that number.
<cfloop index="listitem" list="#restList#" delimiters=",">
<cf_outputResults dID="#val(trim(listitem))#">
</cfloop>
If I output the value of #val(trim(listitem))# in the loop, the first one is
always 0 the second is 112 and the third is 207 (or whatever numbers are in
the list ... problem is, first is always 0)
If I run IsNumeric(val(trim(listitem))) the first is NO, the second YES and
the last is NO, but the last one still evaluates to the correct number
(207,etc.)
If I put a comma in FRONT of the list, they all display correctly.
If there's just one number, it evaluates to 0
Am I going insane or what is it I'm missing? Is there another way to turn a
string value into a number?
Joshua Miller
Eagle Technologies Group, Inc.
www.eagletgi.com
[EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists