name UpdateFiles; -- Copy the contents of fromfile to tofile using the clipboard. We -- are careful to preserve any existing selections in the from file. sub copyfilecontents(fromfile, tofile) savefromselection = fromfile.selection; fromfile.select(startline: 1, endline: fromfile.linecount); fromfile.copy(); if tofile.linecount > 0 then tofile.select(startline: 1, endline: tofile.linecount); endif tofile.paste(); fromfile.select(range: savefromselection); tofile.select(startline: 1, startcolumn: 1); endsub sub copyfiles(connectionname, filelist) pathname = "c:\personal\robelle\1999\hpworld\scripting\"; repeat for filename in filelist fromfile = open(pathname + filename); tofile = open(connection: connectionname, filename: filename); copyfilecontents(fromfile, tofile); tofile.save(); -- saves file, but does not close it writelog(filename + " copied to " + connectionname); fromfile.close(); tofile.close(); endrepeat endsub sub createfilelist filelist = {}; filelist = filelist + "txtags.h"; filelist = filelist + "txcodes.h"; return filelist endsub on command "MPE Server" list = createfilelist(); copyfiles("MPE", list); endon on command "HP-UX Server" list = createfilelist(); copyfiles("HP-UX", list); endon on command "Both" list = createfilelist(); copyfiles("MPE", list); copyfiles("HP-UX", list); endon << Author: david_greer@robelle.com / bgreen@robelle.com Date: Sept 20, 1999 Web: copy02.qsl Comments: 1. This script is an expanded version of copy01.qsl 2. You can't really test it unless you have some PC files to update to some hosts and you modify the scripts to point to your local path and your connection names. 3. This script differs from copy01.qsl in several ways. For one thing it assumes that the local file name and host file name will be the same, with the local files's location defined by the pathname variable and the host files located in the directory defined for the connection. 4. Also, this script is designed to be added to your Script Menu and has commands for copying to the HP-UX host, the MPE host, or both. 5. Notice how lists are used for the file names to be copied. This makes easy to modify the script to update more files. 6. The copy code is also more rigorous. The copyfilecontents() sub saves the existing line selection on from files (which is retained in QWIN's document database on close() and reapplied on the next open() call). After the copy is over, the selection is reset. 7. The copyfilecontents() sub also checks whether the tofile has any existing lines. If so, they are selected so that the subsequent paste() will replace them. 8. The copyfiles() sub shows how you step through a list passed as parameter, processing each member of the list. copyfiles() opens and closes all the files, but calls copyfilecontents() to actually copy the lines. It also writes each file name copied to the log window, which is very useful when you must recover from an error. Note: Copy02.qsl has the same problem as copy01.qsl: if a host file does not exist already, the script will abort. >>