Link to home
Start Free TrialLog in
Avatar of whaleyk
whaleyk

asked on

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>
Avatar of pinaldave
pinaldave
Flag of India image

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
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
ASKER CERTIFIED SOLUTION
Avatar of duroWRX
duroWRX

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi duroWRX,
 
thanks for correcting me...

Regards,
---Pinal
Avatar of whaleyk
whaleyk

ASKER

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]>
Hi whaleyk,
glad it worked out for you. Thank you DuroWRX.

Regards,
---Pinal