Mathew,

Actually you can evaluate functions too e.g.

#Evaluate(Len('foo'))#

Naturally, you can’t easily deal with loop constructs or conditional
logic.

When I said it would technically be possible - I meant it would be
possible by using a suitable mechanism e.g.

You could parse the file by semi-colon and then "Evaluate" each line
e.g.

If the file contained this:

Foo = 'bar';
Bar = 'foo';
Baz = Left(foo & bar,3);

Then you could turn that into:

Evaluate("foo = 'bar'","Bar = 'foo'","Baz = Left(foo & bar,3)");

Or a separate Evaluate for each line. I have done this successfully in
the past when it was advantageous to allow a knowledgable user to enter
some scripting which could then get executed at run time - much like you
would do with VBScript/Javascript.

HOWEVER, this is all way too much for what the original question was.

It all depends on the context of why the include files are being put
into the application scope for in the first place.

If they are being held there to be used dynamically whereby the output
or result of the include is going to be different each time (this is
what I understood) then caching the output using cfsavecontent is not an
appropriate solution.

If, however, it is the output of the include that needs to be cached
then using cfsavecontent to save the output is obviously the way to go.

Under any circumstances it makes no sense to "read" the file in using
cffile only to have to write it out again when you want to include it!
The most suitable approach is just to cfinclude the file as needed.


Regards,

André

-----Original Message-----
From: Matthew Walker [mailto:[EMAIL PROTECTED] 
Sent: 20 June 2003 12:34
To: CF-Talk
Subject: Re: Parse cfm templates stored in a variable?

Actually you can only evaluate expressions, not whole chunks of cfscript
such as loops, functions, etc.

What's wrong with cfincluding them? Also BTW instead of using cffile why
not
simply use cfsavecontent and cfinclude?

Perhaps you might consider cfincluding the CF templates and caching the
result for a given period of time?


Regards,
Matthew Walker
Electric Sheep Web
http://www.electricsheep.co.nz/

----- Original Message ----- 
From: "Andre Mohamed" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, June 20, 2003 10:52 PM
Subject: RE: Parse cfm templates stored in a variable?


> There is no alternative but to "include" the file.
>
> However, if the code is all cfscript, it would technically be possible
> to "evaluate" the whole lot at run time.
>
> André
>
> -----Original Message-----
> From: Peter Mayer [mailto:[EMAIL PROTECTED]
> Sent: 20 June 2003 11:15
> To: CF-Talk
> Subject: Parse cfm templates stored in a variable?
>
> Hello!
>
> I am reading files using cffile and storing them in a application
> variable
> (because they are very often accessed).
>
> If the file is a cfm template I would like to "execute" it - is there
a
> simple way to do that?
>
> The only solution I've seen so far would be to save the application
> variable to a file and than do a cfinclude with that temporary file.
>
> Best regards,
>
> Peter
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Host with the leader in ColdFusion hosting. 
Voted #1 ColdFusion host by CF Developers. 
Offering shared and dedicated hosting options. 
www.cfxhosting.com/default.cfm?redirect=10481

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to