I do a readonly lock on the isDefined check, and cfset a local variable to indicate if 
isDefined is true or not. Use this local variable in the cfif statement, since it 
doesn't have to be locked.

Then use exclusive locks as needed around each write statement.

The idea is that it's better to turn a readonly lock on then off and use exclusive 
locks as needed, than to have to keep an exclusive lock on for much code.

YMMV,
Chris Norloff

---------- Original Message ----------------------------------
From: "Ken Tam" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Date: Thu, 30 Nov 2000 12:35:14 -0800

>This is a multi-part message in MIME format.
>
>------=_NextPart_000_000B_01C05AC9.FD0C4520
>Content-Type: text/plain;
>       charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
>CFlocking large if statements?
>
>How would you go about this if the "if" statement requires a "readonly" =
>and within the if statement requires several "exclusives"? Please have a =
>look at the code below. Any help or suggestions are appreciated.
>
>
><cfif IsDefined("session.variable1")>
>
>        **** bunch of code ****
>
>    <cfset session.variable2 =3D a>
>
>        **** bunch of code ****
>
>    <cfquery name=3D"query name" datasource=3D"#ds#">
>        SELECT column
>        FROM table
>        WHERE columnID =3D #session.variable3#
>    </cfquery>
>
>        **** bunch of code ****
>
>    <cfset session.variable4 =3D b>
>
>        **** bunch of code ****
>
>    <cfset session.variable5 =3D c>
>
>        **** bunch of code ****
>
></cfif>
>
>This if statement and its contents are about 50 lines of code.
>
>Thanks,
>Kenny
>
>------=_NextPart_000_000B_01C05AC9.FD0C4520
>Content-Type: text/html;
>       charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
><HTML><HEAD>
><META content=3D"text/html; charset=3Diso-8859-1" =
>http-equiv=3DContent-Type>
><META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR>
><STYLE></STYLE>
></HEAD>
><BODY bgColor=3D#ffffff>
><DIV><FONT face=3DArial size=3D2>CFlocking large if =
>statements?</FONT></DIV>
><DIV><FONT face=3DArial size=3D2></FONT> </DIV>
><DIV><FONT face=3DArial size=3D2>How would you go about this if the "if" =
>statement=20
>requires a "readonly" and within the if statement requires several =
>"exclusives"?=20
>Please have a look at the code below. Any help or suggestions are=20
>appreciated.</FONT></DIV>
><DIV> </DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2><cfif=20
>IsDefined("session.variable1")></FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2>        =
>**** bunch of=20
>code ****</FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2>    <cfset =
>session.variable2 =3D=20
>a></FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2>        =
>**** bunch of=20
>code ****</FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2>    <cfquery =
>name=3D"query name"=20
>datasource=3D"#ds#"></FONT></DIV>
><DIV><FONT face=3DArial size=3D2>        =
>SELECT=20
>column</FONT></DIV>
><DIV><FONT face=3DArial size=3D2>        =
>FROM=20
>table</FONT></DIV>
><DIV><FONT face=3DArial size=3D2>        =
>WHERE=20
>columnID =3D #session.variable3#</FONT></DIV>
><DIV><FONT face=3DArial size=3D2>    =
></cfquery></FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial =
>size=3D2>        ****=20
>bunch of code ****</FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2>    <cfset =
>session.variable4 =3D=20
>b></FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2>        =
>**** bunch of=20
>code ****</FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2>    <cfset =
>session.variable5 =3D=20
>c></FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2>        =
>**** bunch of=20
>code ****</FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2></cfif></FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2>This if statement and its contents are =
>about 50=20
>lines of code.</FONT></DIV>
><DIV> </DIV>
><DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
><DIV><FONT face=3DArial size=3D2>Kenny</FONT></DIV></BODY></HTML>
>
>------=_NextPart_000_000B_01C05AC9.FD0C4520--
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to