st1 = structNew();
st1.test = "test string";
st2 = st1;
st2.test = "replacement string";
As st2 is a reference to st1, the value of st1.test after running the above code is "replacement string"
Now, whether doing that is a good idea or not is another question. Although I haven't done this in the past I'm tempted to change code like
request.myapp.config.templates.articles.style = "font-size:11px";
to
config.style = "font-size:11px";
I should probably resist though, making code prettier does not necessarily make it easier to maintain.
Mark
"urn:schemas-microsoft-com:office:office" xmlns:w = "urn:schemas-microsoft-com:office:word">
Hi Barry
I programmed in Dataflex for a couple of years, many moons ago, and love Cold Fusion for exactly the same reason: it is an interpreted language. Basically, this means you can do anything you damn well please with it. Anything. I whipped this up after you posed the question, tested it and it works. You can play with it to your heart's content to make it more robust - I only put one check in (to make sure it's an assignment statement).
File: with.cfm
==========
<CFIF thisTag.ExecutionMode EQ "End">
<CFLOOP Index="Line" List="#thisTag.GeneratedContent#" Delimiters="#Chr(13)#">
<CFSET Line=Trim(Line)>
<CFIF Find("=", Line) GT 0>
<CFSET junk = Evaluate("Caller.#Attributes.Var##Line#")>
</CFIF>
</CFLOOP>
<CFSET thisTag.GeneratedContent = "">
</CFIF>
Example usage:
============
<CFSET test = StructNew()>
<CF_With Var="test">
.ele1 = "hello"
.ele2 = "there"
.ele3 = "thexthy"
</CF_With>
Possible enhancement ideas:
1. change delimiters to #Chr(13)# & ";" and then you could have .ele1 = "hello";.ele2="there"; etc etc
2. make the tag recursive or handle nested calls and you could nest <CF_with ...> constructs
HTH Aaron
----- Original Message ----- From: <mailto:[EMAIL PROTECTED]>Barry Beattie
does CF (maybe within CFSCRIPT) have something like VB's WITH keyword when working with object methods and properties?
eg:
WITH myObject
.val1 = var1
.val2 = var2
.addnew()
END WITH
--- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia http://www.mxdu.com/ + 24-25 February, 2004
--- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia http://www.mxdu.com/ + 24-25 February, 2004
