July 24, 2004

Structures in CFMX

CF uses structures quite a bit, there are several internal structures within CF, this encompasses all variable scopes and these can be exploited utilizing structure functions.

First the structures in CF are


  • Application

  • CGI

  • Session

  • Client

  • URL

  • Form

  • Request

  • Server

  • Cookie

  • Attributes

  • CFCatch

  • CFError

  • CFFtp

  • CFHttp

  • File

  • ThisTag


So let's say you wanted to clear session variables, try using
<cfscript>
structclear(session);
</cfscript>

Or let's say you wanted to verify that a form submission caused an action page.
<cfif structkeyexists(form, "fieldvalue")>

There are several uses that can be manipulated.


Posted by Elyse at July 24, 2004 11:49 AM | TrackBack
Comments

you missed out the arguments scope although here's a "gotcha" interaction between scopes...

I had grief with CFFUNCTION and an argument variable being the same name as a local (var) variable.

<cffunction name="test" returntype="string">
<cfargument name="myVar" type="string">
<cfset var myVar = "test2">

this will error, even though it seems they belong to two different scopes (local and argument). "Cannot declare local variable myVar twice"

seems like the arguments scope is copied into the local function scope after the cfargument tags, so all arguments are also in the local var scope

just thought I'd bring it up since scopes do interact - they *are* just structs - like Elyse said...

cheers
barry.b

Posted by: barry.b at July 25, 2004 8:08 AM
Post a comment









Remember personal info?