Contents Previous Next Subchapters

Comparing And Updating Source Files
Syntax update(filedirectory)
update(
filedirectory, function callback)
See Also filediff

Description
Compares a new version of a file with an old version in the specified directory and then posts a dialog that asks the user if the new one should replace the old one. If the user agrees, the old version of the file is overwritten with a copy of the new one. The character row vector file specifies the name of the new file relative to the current directory (as would be returned by cwd ). The character row vector directory specifies the name of the directory in which the old version of the file is stored. The old version of the file has the same name in directory as the new version has in the current directory.

The user cannot choose his option until O-Matrix is done executing the thread of commands in which the call to update is a part. When the user does make his choice, a new execution thread is started. If the function callback is present, the function call callback(replace) is make after update finishes its operation. The argument replace is true if the file was replaced and false otherwise.

Example
Suppose that the file temp.oms in the current directory contains
     clear
     version = "new"
     #
     print "This is the", version, "version"
     print "done"
In addition, the file temp.oms in the directory c:\omwin\programs contains
     clear
     version = "old"
     #
     print "This is the", version, "version"
     print "done"
If at the command line you enter
     file      = "temp.oms"
     directory = "c:\omwin\programs"
     update(file, directory)
O-Matrix will print
     difference: temp.oms <> c:\omwin\programs\temp.oms
     <version = "new"
     >version = "old"
in the command window and then ask if you wish to replace the old version with the new on. (Note that text from the new version is preceded by < and text from the old version is preceded by >.) If you agree, the file temp.oms in the directory c:\omwin\programs will be replaced. In any event, a message telling if the file has been replaced is printed in the command window.

Reference
Only the first 100 character in each line are considered when determining the differences between the files.