Code improvements... cfif neq and cfif neq and cfif neq..... etc.

Hi everyone, this code works, but any suggestions for cleaning up that awfully long "if" statement.. thanks as always!
======================================================================

<CFLOOP ITEM="i" COLLECTION="#FORM#">
<CFSET VAR.FieldID=ListGetAt(i, 1)>

<CFIF i NEQ "FIELDNAMES" AND i NEQ "UPDATEQUESTIONID" AND i NEQ "LOOPCOUNT" AND i NEQ "SQLTABLE" AND i NEQ "NEXTQUESTION" AND i NEQ "MODIFYQUESTION" AND i NEQ "MODIFYINGCURRENTLOOP" AND  NEQ "ANSWERRECAPCONFIRM" AND i NEQ "LASTGROUPQUESTION" AND i NEQ "PRIORRESPONSE">

<CFSET i=FORM[i]>

<CFLOCK timeout="10" throwontimeout="Yes" type="exclusive" scope="SESSION">
<CFTRANSACTION>
<CFQUERY datasource="mine">
INSERT INTO dbo.eZWizard_Usage_FieldLevel(UsageID,UserID,EventID,QuestionID,FieldID,Count,Response)                  
VALUES(#SESSION.eZWizardUsageID#,#qGetInvestorLevelUsage.UserID#,#SESSION.EventID#,#FORM.UpdateQuestionID#,#VAR.FieldID#, #FORM.ModifyingCurrentLoop#,'#i#')
</CFQUERY>
</CFTRANSACTION>
</CFLOCK>

</CFLOOP>
whaleykAsked:
Who is Participating?
 
duroWRXConnect With a Mentor Commented:
I agree with Pinal on his second answer, but I would do

<cfif listfind(yourlist,i)>

instead ;)
0
 
pinaldaveCommented:
Hi whaleyk,

instead of i neq "" you should use something like
<cfloop of i>
<cfset yourlist = "fieldsname,updatequeryind......">

<cfif yourlist contains i>

do things

</cfif>
</cfloop>

Regards,
---Pinal
0
 
pinaldaveCommented:
Hi whaleyk,
looking at your code again may be you need to use something like this...

<cfloop of i>
<cfset yourlist = "fieldsname,updatequeryind......">

<cfif yourlist contains i>
do nothing
<cfelse>
do seomthing
</cfif>
</cfloop>

do you need any more info or explaination?

Regards,
---Pinal
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
pinaldaveCommented:
Hi duroWRX,
 
thanks for correcting me...

Regards,
---Pinal
0
 
whaleykAuthor Commented:
Both will work, but I think this works better...
Thanks both :-)

<CFLOOP ITEM="i" COLLECTION="#FORM#">
<cfset VAR.FieldID=ListGetAt(i, 1)>
<cfif NOT listFindNoCase("FieldNames,UpdateQuestionID,LoopCount,SQLTable,NextQuestion,ModifyQuestion",i)>
<cfset i=FORM[i]>
0
 
pinaldaveCommented:
Hi whaleyk,
glad it worked out for you. Thank you DuroWRX.

Regards,
---Pinal
0
All Courses

From novice to tech pro — start learning today.