Nash - Scientific Computing with PCs (523165), страница 30
Текст из файла (страница 30)
Because of the powerand richness of features, BRIEF strains the "simplicity" criterion.For making complex changes to text files, a macro editor (Section 2.6) is helpful. It allows sequences ofcommands to be executed from a script. We find such a tool invaluable for adjusting the layout of dataor output files. On the negative side, macro editors may be more awkward to use. One keystroke can doa lot of work — or damage! The macro editor we use in our own work is SEE, for which we purchasedand modified the C source code some time ago. It has a limited but useful macro facility and a line wrapfeature helpful in adjusting text file widths for display and printing.
Unfortunately, SEE’s producers havenot replied to our letter. BRIEF, mentioned above, is also a macro editor.Editors are also used for viewing files. It is critical that one have at least one editor that can handle verylarge files reliably. Many editors try to hold the entire file of text in memory, so are limited either bymemory size or memory addressing. This includes our own freeware NED (Nash J C 1990a), but not itscommercial counterpart.We regard word processing and desktop publishing as applications rather than utilities (Chapter 2).Section 10.3 discusses their use in data file reformatting.10.2 File Move, Copy, Archive and BackupA single utility for viewing, moving and copying files has yet to appear on our machines.
The featureswe want exist in separate utilities. User interfaces vary. Some use commands with switches, some a "tagand go" approach, while still others employ the "click and drag" mechanism made popular by the AppleMacintosh. Our preference is to tag files then issue a command for an operation to be made on thesetagged files. While "tagging", it is helpful to be able to view or edit the files, at least if they are plain text.We want to do all this with a minimum of keystrokes.Several utilities in public collections allow almost the functionality just described, but a separate utilitymust be used to move whole directories.
Macintosh’s "click and drag" allows this, but it fails to allow easyuse of wildcards, that is, the specification of a group of files by giving a filename having some charactersreplaced by place holders for regular characters. The MS-DOS operating system uses a "?" to replace anyregular character and "*" to replace any characters to the end of the main filename or the filenameextension. Thus the filename specification FILE????.C* can refer to FILECOPY.COM FILELIST.CMD orFILEDUMP.C but not FILEDEL.COM or FILECOPY.EXE.We use special utilities to copy or move files only if the source version is more recent than the target.Copying "old" over "new" is a common and annoying source of data loss.While we continue to watch for a file manipulation utility that is ideal from our own perspective, thereare many good programs available and operating system facilities are improving.
Windowedenvironments have built-in facilities many users find satisfactory (we find them a little slow and awkwardto use). Some hypertext processors allow users to develop their own "utility" by gluing together a set ofexisting programs and launching them under control of a hypertext script.A utility that in some ways comes close to what we would like is the Laplink transfer utility intended for86Copyright © 1984, 1994 J C & M M NashNash Information Services Inc., 1975 Bel Air Drive, Ottawa, ON K2C 0X1 CanadaSCIENTIFIC COMPUTING WITH PCsCopy for:Dr.
Dobb’s Journalmovement of data between portable and stationary PCs. For users of notebook PCs a utility of this typethat can transfer data easily via serial or parallel ports is almost essential. Macintosh machines have a formof networking built in, so do not have quite the same needs.Compressed archives can be a nuisance to move and copy, since we cannot move files in and out of themas we would with directories. In Section 5.5 we have discussed the merits of compression and archiving.We recommend that users select just one such tool to use regularly.
Since others may package softwareusing a variety of archiving tools, it is helpful to have the "unpacking" part of several tools. It is easy towrite BATch command files that unpack from different compressed forms and repack into the form onwhich we have standardized.Backup was discussed in Section 5.5. Users should standardize on a single backup tool, preferably onethat allows all backup to be carried out at a single workstation PC with a minimum of human effort.
Westrongly recommend testing the recovery of files from the backup medium; also the development ofpolicies and practices for the safe storage of the backup media.For making copies of disks we find a utility that does requires us to swap disks just once helpful. We useDCOPY by Scott Abramowitz when we need to make a security copy of new software disks or when wewant to make disks to distribute our work.10.3 File Display, Conversion and PrintFiles often need to be printed, but various types of files may need to be treated differently. Someimportant possibilities are:•Program listings (Assembly code, BASIC, FORTRAN, PASCAL, MATLAB, Stata, SAS, C, DBASE);•Data files (binary numeric files, text numeric or mixed numeric/string data, text processing files withformatting commands, spreadsheet files, database files, hypertexts);•Graphics (drawing or CAD files, various graphic output format files, scanned images or faxes,PostScript files for printing).Program listings require some formatting.
We may want indenting of loops, separation of statements inmulti-statement lines, positioning of comments, and general cleanup of the presentation. Tabs may havebeen used for indenting program statements. Assembly listings need the labels (if any), instructions,operands, and comments lined up in appropriate columns for ease of reading. Extra functionality mayallow formatting commands to be included, such as setting tab positions, pagination, titling, forced pagethrow, and special character sets.Data files for particular applications may need highly specific listing programs.
For example, a file ofrandom digits could store two digits per byte in binary-coded decimal form. To list such a file, each bytemust be read, split into two digits, each digit converted to its character form, and the character form ofeach digit printed.Text files are easier to list, except that at the end of each line the PC must perform a carriage return andline feed. This can be signalled by a carriage return character in the file. More sophisticated lists can usethe "carriage return" character as an end of paragraph marker, with automatic line splitting to somespecified maximum line length. Note that UNIX text files have line feed rather than carriage returncharacters (Nash J C, 1993a).Files of unknown origin may require a viewer that can display the data in various translations of thebinary data, for instance as text, as hexadecimal digits, or perhaps even as binary bits.10: UTILITIES - A DESIRABLE SET87Mixed data types create difficulties since each file configuration will need its own lister.
The MacintoshFINDER overcomes this by loading the appropriate application program when a file of a given type isselected. This fails if the application is not available on the present Macintosh. We also find that it can beannoyingly slow for "large" applications that take time to load.Beyond display, we may need to be able to convert one form of file to another, preferably in a way thatis reversible. From the standpoint of automating the conversion tasks, it is helpful to have standaloneutility programs to do such conversions, for then the commands can be put into a batch file and executedwhile we do something else.
We have found a few such utility programs, though some are less thanperfectly reliable. We chose DBMS COPY for converting statistical and database formats.Some file management utility programs claim to be able to display a variety of file types, and to do soautomatically. Because they are trying to be encyclopedic, such programs have a tendency to need a lotof program code to cover all the file types. We prefer to manage our way around this problem. That is,we try to select just a few different formats with which we will work. Our choices at the time of writingare as follows.•Data files are kept in text form, preferably with commentary if the application programs allow this.We also keep memos, letters and outgoing faxes in plain text form if possible.•Reports, formal letters, manuscripts, etc. are kept in the format of WordPerfect 5.1, which was usedto write this book.
We are not great fans of WordPerfect, but the mass of users in our community ofcolleagues makes it a sensible choice. This standardizes our word processing / report preparationformat.•Graphics files are kept in a form that can be imported reliably into the chosen word processor. (TheGRAPHCNV program for WordPerfect can be used in batch command files.) The formats we havefound most helpful are HPGL (Hewlett-Packard’s graphic language) and Lotus PIC files, with a poorsecond choice being various files in the PCX format. The PCX form is a bitmap, so images lack thecrispness allowed by the other formats when graphics are scaled to fit into reports.
Bitmaps arisewhen images are scanned optically or captured from a screen (see examples in Chapter 19).•Our own program codes are kept only in source code form along with scripts for their compilationunless we are running the programs daily. This saves much space and allows us to view the contentsof the program.Note that conversion of files between types can to some extent be accomplished using import and exportfacilities within application programs. By restricting the formats we use, we can reduce the number ofconversion tools needed and ensure their reliability.10.4 File ComparisonA file comparison utility is essential when we wish to determine if two files are identical, such as inverifying disks for transmission to other users, ensuring all copies of similarly named files are the same,or checking the read/write hardware or disk media.File comparison may be awkward if end-of-file markers are used.