Skip to main content
Participant
July 14, 2006
Question

Loop that wont produce repeat product ids

  • July 14, 2006
  • 1 reply
  • 265 views
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>
This topic has been closed for replies.

1 reply

Inspiring
July 15, 2006
Does the code you have not work ?

If not, is there an error or it just does not find the value ?

Couple of suggestions:
I assume from the code the file is a comma seperated list ?

Unless you are using the array elsewhere there is no need for it, just use the list

Then you could just use ListContainsNoCase(list, substring [, delimiters ]) or just ListContains if the case is important

See attached

Ken