Question
Loop that wont produce repeat product ids
Need help comparing the new product varible to the values in
the array.
I wish to enter a 'productid' and reference that 'productid' to already created product ids---Need Help with the loop I have created and array:
<cffile action="read" file="C:\CFusionMX7\wwwroot\test\itemcodes.txt" variable="icfromfile" charset="UTF-8">
<cfdump var="#icfromfile#">
<!--- Store the data from product codes into an array --->
<cfset ItemCodes=ArrayNew(1)>
<cfset ItemCodes = #ListToArray(icfromfile)#>
<cfdump var="#ItemCodes#" label="Item Codes">
<!--- Compare the variable in form.ItemCode with all variables in the array --->
<cfset codein = "item01">
<cfset ItemCodeArrayLen = ArrayLen(ItemCodes)>
<cfloop index="count01" from="1" to="#ItemCodeArrayLen#">
<cfif ItemCodes[count01] eq codein>
<cfset codein = True>Found
<cfesle>
<cfset codein = False>Not
--------Need Help-------------------------
</cfloop>
I wish to enter a 'productid' and reference that 'productid' to already created product ids---Need Help with the loop I have created and array:
<cffile action="read" file="C:\CFusionMX7\wwwroot\test\itemcodes.txt" variable="icfromfile" charset="UTF-8">
<cfdump var="#icfromfile#">
<!--- Store the data from product codes into an array --->
<cfset ItemCodes=ArrayNew(1)>
<cfset ItemCodes = #ListToArray(icfromfile)#>
<cfdump var="#ItemCodes#" label="Item Codes">
<!--- Compare the variable in form.ItemCode with all variables in the array --->
<cfset codein = "item01">
<cfset ItemCodeArrayLen = ArrayLen(ItemCodes)>
<cfloop index="count01" from="1" to="#ItemCodeArrayLen#">
<cfif ItemCodes[count01] eq codein>
<cfset codein = True>Found
<cfesle>
<cfset codein = False>Not
--------Need Help-------------------------
</cfloop>