| **Navigation:**  [[templates.htm|Templates]] > [[tlrcontents.htm|Template Language Reference]] > Complete Alpha Listing >====== #REPLACE (conditionally replace source file) {{c6h0068.jpg|C6H0068.jpg}} ====== | [[ remove delete a source file .htm|{{btn_prev_n.gif|Previous page}}]][[tlrcontents.htm|{{btn_home_n.gif|Return to chapter overview}}]][[ reports default report structures .htm|{{btn_next_n.gif|Next page}}]] | | || **#REPLACE(** //oldfile, newfile// **)** {{blk2blue.jpg|blk2blue.jpg}} | **#REPLACE** | Performs "intelligent" file replacement. | | //oldfile// | A string constant, template symbol, or expression containing a DOS file specification. This may be a fully qualified DOS pathname. | | //newfile// | A string constant, template symbol, or expression containing a DOS file specification. This may be a fully qualified DOS pathname. | The **#REPLACE** statement performs a binary comparison between the contents of the //oldfile// and //newfile//. If the contents of the //oldfile// are different from the contents of the //newfile// (or the //oldfile// does not exist), then the //oldfile// is deleted and the //newfile// is copied to the //oldfile//. If the two files are identical, then no action is taken. If the //newfile// does not exist, #REPLACE is ignored and source generation continues. **Example:** **#FOR(%Module)** **   #SET(%TempModuleFile,(%Module & '.$$$'))          #!Set temp module file** **   #CREATE(%TempModuleFile)                          #!Create temp module file** **   #GENERATE(%Module)                                #!Generate module header** **   #FOR(%ModuleProcedure)                            #!For all procs in module** **      #FIX(%Procedure,%ModuleProcedure)              #!Fix current procedure** **      #GENERATE(%Procedure)                          #!Generate procedure code** **   #ENDFOR                                           #!EndFor all procs in module** **   #SET(%ModuleFile,(%Module & '.CLW'))              #!Set to existing module file** **   ****#REPLACE****(%ModuleFile,%TempModuleFile)             #!Replace old with new (if changed)** **#ENDFOR**