3

I have my query outputted in structure. Then I have my array where I loop through. I want to compare value from my structure and my array. First to compare array value 1 and key of my structure, if they are the same I have another if statement where I want to compare array value 23 and my structure value code, if they are not the same I store array value 1 in the list. Here is my code that I have so far:

<!--- loop that populates myStruct --->
<cfloop query="getCustomers">
    <cfset myStruct[Cutomer_Number] = {id1=ID,code=CS_CODE}>
</cfloop>

<cfloop index="i" from="1" to="#(cnt)#" step="1">   
    <cfif len(trim(myarray[i])) GT 0>
        <cfset myrow = #replace(myarray[i],chr(10),'')#>
        <cfset myrow = ListToArray(myrow,",",true)>

        <!--- this if statement works where I compare my key and row 1 from    array --->
        <cfif structKeyExists(myStruct,myrow[1])>
<!--- here I want to check if CS_CODE and row 2 are different--->
            <cfif structFindValue(myStruct.CS_CODE,myrow[2])>
                <cfoutput>#count# - #myrow[1]# - #myrow[2]#</cfoutput><br>
            </cfif>
        </cfif>
        <cfset count++>
    </cfif>
</cfloop>

I'm getting an error that CS_CODE variable does not exist. I'm definitely doing something wrong when I try to access value from my struct and also structFindValue might not be something that I need to compare struct value and array value. I need something that is same as NEQ in coldfusion. If anyone can help with this problem please let me know.

4
  • Is this structFindValue(myStruct[myrow[1]],myrow[2]) what you are trying to do? Commented May 24, 2016 at 18:40
  • I'm trying to compare value from my structure and value from my array. Commented May 24, 2016 at 18:42
  • 1
    Try this <cfif structFindValue(myStruct[myrow[1]].code, myrow[2])>. Commented May 24, 2016 at 18:48
  • That works, thank you! Commented May 24, 2016 at 18:51

1 Answer 1

3

You can access the data like this.

<cfif structFindValue(myStruct[myrow[1]].code, myrow[2])>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.