#REPLACE (conditionally replace source file) 

Top  Previous  Next

 

#REPLACE( oldfile, newfile )

#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