Where is fileInfo declared as a new array?
Shouldn't that be the first step inside your loop?
Just curious.
Al

P.S. Just for debugging fun, add i as an array element too.


On 1/6/2014 7:48 PM, Magnus wrote:
I am trying to create an array of structs from values passed from a form. Using this code, the resulting array has the same value in each array cell from last iteration of the loop. The desired result, of course, is toi hae each pair of form values passed to a struct in each array cell. As far as I can tell, it seems the earsh array cell is only a reference to the fileInfo struct which gets rewritten each loop. I can't recall where I have read about assigning vallues and referencing variables in CFML to help me clarify wht is going on and how to get it working as I want. (If you are wondering, the form is from Plupload for uploading files.

I want ot put the valuesinto an array because I will be doing a bunch of operations to or on the files and looping over and array each time will be simplier can repeatedly dealing with the dynamically generated form variables. Any help getting on track and beter understanding what is goingon here is much appeciated.

Magnus


<cfdump var="#FORM#"> ...the starting values...
struct
FIELDNAMES UPLOADER_0_NAME,UPLOADER_0_STATUS,UPLOADER_1_NAME,UPLOADER_1_STATUS,UPLOADER_2_NAME,UPLOADER_2_STATUS,UPLOADER_3_NAME,UPLOADER_3_STATUS,UPLOADER_4_NAME,UPLOADER_4_STATUS,UPLOADER_COUNT
UPLOADER_0_NAME ANGELS.wav
UPLOADER_0_STATUS  done
UPLOADER_1_NAME Kalimba.mp3
UPLOADER_1_STATUS
done
UPLOADER_2_NAME Machine_Gun_Alley_1.ogg
UPLOADER_2_STATUS
done
UPLOADER_3_NAME Maid with the Flaxen Hair.mp3
UPLOADER_3_STATUS  done
UPLOADER_4_NAME Sleep Away.mp3
UPLOADER_4_STATUS 
done
UPLOADER_COUNT 5

Here is the code..
<cfset fileArray = arrayNew(1)>
<cfloop index="i" from="0" to="#FORM.uploader_count-1#" step="1">
    <cfset fileInfo.name=#Evaluate("FORM.uploader_" & i & "_name")#>
    <cfset fileInfo.status=#Evaluate("FORM.uploader_" & i & "_status")#>
    <cfset fileArray[i+1] = fileInfo>
    <cfdump var="#fileInfo#"
   
</cfloop>

<cfdump var="#fileArray#"> ...the end result...
array
1  
struct
name Sleep Away.mp3
status  done

2
struct
name Sleep Away.mp3
status
done

3
struct
name Sleep Away.mp3
status  done

4
struct
name Sleep Away.mp3
status  done

5
struct
name Sleep Away.mp3
status  done

--
--
online documentation: http://openbd.org/manual/
http://groups.google.com/group/openbd?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Open BlueDragon" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

--
--
online documentation: http://openbd.org/manual/
http://groups.google.com/group/openbd?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Open BlueDragon" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to