It is actually possible, but it is NOT A GOOD IDEA. I cannot stress it
enough, DO NOT DO IT that way, it makes your code near impossible to debug.
Here is a function to do it though to prove that is CAN be done, just in
case you are curious how to do it:
<!---------------------- start code ----------------------------->
<cfscript>
function parseToEvalString(parseString){
var startAt = 1;
var returnString = '';
var returnVar = '';
var findStruct = reFind("([##])+([^##]+)([##])+", parseString, startAt,
true);
while(val(findStruct.len[1] + findStruct.pos[1]) neq 0){
returnString = returnString & mid(parseString, startAt,
val(findStruct.pos[1] - startAt));
returnVar = mid(parseString, findStruct.pos[1], findStruct.len[1]);
if(isDefined(replace(returnVar, "##", "", "ALL"))){
returnString = returnString & evaluate("#returnVar#");
}else{
returnString = returnString & returnVar;
}
startAt = findStruct.pos[4] + 1;
findStruct = reFind("([##])+([^##]+)([##])+", parseString, startAt,
true);
}
returnString = returnString & right(parseString, val(len(parseString) -
startAt + 1));
return returnString;
}
</cfscript>
<cfset dateVar = now()>
<cfset nameVar = "Nate">
<!--- the double pounds wouldn't have to exist in a db, have to use in CF
to escape them --->
<cfset testString = "The current date is ##dateVar##. Thanks for visiting my
page ##nameVar##!">
<cfoutput>
#parseToEvalString(testString)#
</cfoutput>
<!---------------------- end code ----------------------------->
So in other words, you could do the following and it WOULD work:
<cfoutput>#parseToEvalString(queryname.columname)#</cfoutput>
The function works with multiple vars in a single string, in case you can't
tell by test string.
Now, one exception above is that it will not work on function outputs like
#now()# - that is because of the isDefined() statement above, if you change
that to a try{}catch{} block, they WILL work, but then the code is CFMX
compatible only (function above is CF5 and MX).
take care,
Nate Nielsen
[EMAIL PROTECTED]
----- Original Message -----
From: "Ken Ferguson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 27, 2004 7:36 AM
Subject: RE: dynamic data inside a column value
Of course that works. You're setting the variable so that what comes
across in the url is ".cfm?t=myonetwothreestatement", but I'm setting it
so that what comes out is ".cfm?t=#variables.tvariable#". See, what he
is asking is if he can put a string surrounded by pound signs into the
database and then output that, but get the variable value -- not the
string. So, in his database column, he'd actually have
"#variables.tvariable#". Then he wants to do this:
<cfoutput>#queryname.columname#</cfoutput> and get the value of
variables.tvariable.
That's what I am saying WILL NOT work.
--Ferg
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Phillip Holmes
Sent: Friday, September 24, 2004 3:37 PM
To: [EMAIL PROTECTED]
Subject: RE: dynamic data inside a column value
Works fine here:
<cfset variables.tvariable = 'onetwothree'>
<cfoutput><a
href="test.cfm?t=my#variables.tvariable#statement">test</a></cfoutput>
<cfif IsDefined("url.t")>
<cfoutput>#url.t#</cfoutput>
</cfif>
Yields: myonetwothreestatement
Regards,
Phillip B. Holmes
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf
Of Ken Ferguson
Sent: Friday, September 24, 2004 2:26 PM
To: [EMAIL PROTECTED]
Subject: RE: dynamic data inside a column value
No Sravan, I don't think this will work. I've not tested whether it will
or
not and I've never tried to do that, but I think it will fail. I did run
a
little test like this:
I pointed a browser to /test.cfm?t=my#variables.tvariable#statement
And on that page I had this:
<cfset variables.tvariable = "test">
<cfoutput>#t#</cfoutput>
And this yielded the output "my" and nothing else -- no errors, but the
rest
of the statement was missing.
I think my suggestion below might be a better idea or maybe somebody can
think of something even better. Is there any reason that won't work for
you?
--Ferg
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf
Of Sravan kumar
Sent: Friday, September 24, 2004 12:03 PM
To: [EMAIL PROTECTED]
Subject: RE: dynamic data inside a column value
Correct. This will help me.
i was thinking like inserting the text "this is #dynamictext# test
column"
in the database column and when outputting, surround it with cfoutput
tags.
Does that work?
Thank you,
Sravan
>From: "Ken Ferguson" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: <[EMAIL PROTECTED]>
>Subject: RE: dynamic data inside a column value
>Date: Fri, 24 Sep 2004 10:23:53 -0500
>
>Not sure I follow you completely, but assuming the value of
>queryname.column is "this is ~ test column" and you wanted to replace
>the "~" with a variable you have defined on your page - variables.myvar
>then you could do something like:
>
><cfoutput>#replace(queryname.column,"~","variables.myvar")#</cfoutput>
>
>Which would yield, assuming the value of variables.myvar was "my":
>"this is my test column"
>
>Is this the sort of thing you're after, or have I completely
>misunderstood what it is you're looking for?
>
>--Ferg
>
>
>
>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
>Behalf Of Sravan kumar
>Sent: Friday, September 24, 2004 10:03 AM
>To: [EMAIL PROTECTED]
>Subject: dynamic data inside a column value
>
>Hi,
>
>What is the best way to hold place holders inside a database column
>value?
>In other words, i want to query the database to display the value of a
>column. In that output, some where in the middle,i would like to
replace
>few
>place holders with a dynamica value. Is it possible?
>
>Thanks
>Sravan
>
>_________________________________________________________________
>Express yourself instantly with MSN Messenger! Download today - it's
>FREE!
>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>----------------------------------------------------------
>To post, send email to [EMAIL PROTECTED] To unsubscribe:
> http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
>To subscribe:
> http://www.dfwcfug.org/form_MemberRegistration.cfm
>
>
>
>----------------------------------------------------------
>To post, send email to [EMAIL PROTECTED] To unsubscribe:
> http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
>To subscribe:
> http://www.dfwcfug.org/form_MemberRegistration.cfm
>
>
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
----------------------------------------------------------
To post, send email to [EMAIL PROTECTED]
To unsubscribe:
http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
http://www.dfwcfug.org/form_MemberRegistration.cfm
----------------------------------------------------------
To post, send email to [EMAIL PROTECTED]
To unsubscribe:
http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
http://www.dfwcfug.org/form_MemberRegistration.cfm
---
[This E-mail has been scanned for viruses.]
---
[This E-mail has been scanned for viruses.]
----------------------------------------------------------
To post, send email to [EMAIL PROTECTED]
To unsubscribe:
http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
http://www.dfwcfug.org/form_MemberRegistration.cfm
----------------------------------------------------------
To post, send email to [EMAIL PROTECTED]
To unsubscribe:
http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
http://www.dfwcfug.org/form_MemberRegistration.cfm
----------------------------------------------------------
To post, send email to [EMAIL PROTECTED]
To unsubscribe:
http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
http://www.dfwcfug.org/form_MemberRegistration.cfm