Re: Editing Files In-Line

2003-09-23 Thread Paul Giesenhagen
It will have to open it up. 
 
Use  
 
 

 
 

 
 
That should getcha! 
 
Paul Giesenhagen 
QuillDesign 
 
 
  - Original Message -  
  From: Richard Crawford  
  To: CF-Talk  
  Sent: Tuesday, September 23, 2003 11:29 AM 
  Subject: Editing Files In-Line 
 
 
Is there a way in Cold Fusion to make changes to a text file without   
actually opening that file?  
  
Suppose, for example, that I have a file "myfile.html" which contains   
the string "***REPLACE_THIS***".  How can I have Cold Fusion replace   
that string in the file?  
 

~|
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]



RE: Editing Files In-Line

2003-09-23 Thread Mosh Teitelbaum
Richard Crawford wrote:
 Is there a way in Cold Fusion to make changes to a text file without
 actually opening that file?

Well, that really depends on what you mean by open.  Regardless though,
you can accomplish what you're looking for...

 Suppose, for example, that I have a file myfile.html which contains
 the string ***REPLACE_THIS***.  How can I have Cold Fusion replace
 that string in the file?

Your code would look something like:

!--- Read contents of file to a variable ---
CFFILE ACTION=Read FILE=C:\Temp\myFile.html VARIABLE=fileContents

!--- Replace place holder text ---
CFSET fileContents = Replace(fileContents, ***REPLACE THIS***, Hi
Mom!)

!--- Overwrite file with new contents ---
CFFILE ACTION=Write FILE=C:\Temp\myFile.html OUTPUT=#fileContents#

The above code would replace the place holder text with Hi Mom.

--
Mosh Teitelbaum
evoch, LLC
Tel: (301) 942-5378
Fax: (301) 933-3651
Email: [EMAIL PROTECTED]
WWW: http://www.evoch.com/

~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:138144
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm


RE: Editing Files In-Line

2003-09-23 Thread Shawn Grover
 
 
  
Then if need be, you can do a cffile with action="" to write out the 
modified file, or just dump sFileContent to the client. 
  
This may not be the most elegant solution, but it'll work... (a regular 
_expression_ replace might be much more efficient). 
  
Shawn 
 
-Original Message- 
From: Richard Crawford [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 23, 2003 10:29 AM 
To: CF-Talk 
Subject: Editing Files In-Line 
 
 
Is there a way in Cold Fusion to make changes to a text file without   
 
actually opening that file?  
 
  
 
Suppose, for example, that I have a file "myfile.html" which contains   
 
the string "***REPLACE_THIS***".  How can I have Cold Fusion replace   
 
that string in the file?  
 
  

~|
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]



RE: Editing Files In-Line

2003-09-23 Thread Shawn Grover
H. now that mail is being sent as HTML, I'm not seeing tags that are 
being discussed 
  
  
 
-Original Message- 
From: Paul Giesenhagen [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 23, 2003 10:34 AM 
To: CF-Talk 
Subject: Re: Editing Files In-Line 
 
 
It will have to open it up.  
 
  
 
Use   
 
  
 
  
 
 
 
  
 
  
 
 
 
  
 
  
 
That should getcha!  
 
  
 
Paul Giesenhagen  
 
QuillDesign  
 
  
 
  
 
  - Original Message -   
 
  From: Richard Crawford   
 
  To: CF-Talk   
 
  Sent: Tuesday, September 23, 2003 11:29 AM  
 
  Subject: Editing Files In-Line  
 
  
 
  
 
Is there a way in Cold Fusion to make changes to a text file without
 
actually opening that file?   
 
   
 
Suppose, for example, that I have a file "myfile.html" which contains
 
the string "***REPLACE_THIS***".  How can I have Cold Fusion replace
 
that string in the file?   
 
  

~|
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]



RE: Editing Files In-Line

2003-09-23 Thread Matt Robertson
Richard Crawford wrote: 
>Is there a way in Cold Fusion to make changes to a text file without   
>actually opening that file?  
 
*something* will have to open it. :-) 
 
>Suppose, for example, that I have a file "myfile.html" which contains   
>the string "***REPLACE_THIS***".  How can I have Cold Fusion replace   
>that string in the file?  
 
Use CFFILE to read the file into a variable.  Then do a Replace() on the 
desired string.  Then use CFFILE to write the altered variable value to 
a 'new' file (or overwrite the old one). 
 
 
 Matt Robertson   [EMAIL PROTECTED]  
 MSB Designs, Inc.  http://mysecretbase.com 
 

~|
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]



Re: Editing Files In-Line

2003-09-23 Thread Richard Crawford
This is the code I'm using:

cffile action=copy mode=0777 
source=/space/usr/jrun4/servers/default/cfusion/DLC/include/disboard/wwwboard.html 
destination=/space/usr/jrun4/servers/default/cfusion/DLC/Campus/Courses/#course.xURL#/extras/disboard/#nNumber#/
cffile action=read 
file=/space/usr/jrun4/servers/default/cfusion/DLC/Campus/Courses/#course.xURL#/extras/disboard/#nNumber#/wwwboard.html
 
variable=thisFile
cfset thisFile=ReplaceNoCase(thisFile, actionurl, 
http://unexdlc.ucdavis.edu/DLC/Campus/Courses/#course.xURL#/extras/disboard/#nNumber#/wwwboard.pl;)
cffile action=write 
file=/space/usr/jrun4/servers/default/cfusion/DLC/Campus/Courses/#course.xURL#/extras/disboard/#nNumber#/wwwboard.html
 
output=#thisFile# addnewline=no


Unfortunately, this does not seem to be working.  Any thoughts?  Help!


~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:138158
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com


Re: Editing Files In-Line - SOLVED

2003-09-23 Thread Richard Crawford
I figured it out.  My file was being changed successfully, but then 
being overwritten by the original file because of a cffile 
action=copy tag that I'd forgotten to remove.

So now I am off to get another cup of coffee.  Oy.


~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:138180
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm