Scripting Example 25

; Example25.ftp

; =============

; This example copies the content of the file

; AUTOEXEC.BAT to another file, appending it

; to the new file if it does exist,

; otherwise creates the file.

; The files are opened and each line is read

; from one file and added to the other.

; -------------------------------------------

; Commands demonstrated:

; OUTPUTAPPEND

; OUTPUTWRITE

; INPUTOPEN

; INPUTREAD

; ADDTOFILE

; EDITFILE

; -------------------------------------------

 

 

OutputAppend 1 "C:\SytemsFiles.new"

if success then

goto next1

endif

Message "Could not open output file!"

goto End

 

:Next1

InputOpen 1 "C:\Autoexec.bat"

if success then

goto next2

endif

Message "Could not open input file!"

goto End

 

:Next2

 

:NextLine

InputRead 1 A

if success then

OutputWrite 1 "%%A%%"

goto NextLine

endif

OutputClose 1

InputClose 1

 

; Show the result by displaying the new file

; in the built in editor;:

EditFile A "C:\SytemsFiles.new"

 

; Add the text "FileEnd" to the end of the written file:

AddToFile "C:\SytemsFiles.new" "--FileEnd--%%NEWLINE%%"

 

; Show the result by displaying the new file

; in the built in editor;:

EditFile A "C:\SytemsFiles.new"

 

:end