User Tools

Site Tools


replace_conditionally_replace_source_file_.htm
Navigation:  Templates > Template Language Reference > Complete Alpha Listing >====== #REPLACE (conditionally replace source file) C6H0068.jpg ====== Previous pageReturn to chapter overviewNext page

#REPLACE( oldfile, newfile )

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

replace_conditionally_replace_source_file_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)