General HydroStatics
Ship Stability Software |
Command of the Week
(New or interesting aspects of GHS that you may not know about) |
DIR /MACRO
|
Browsing through the GHS manual looking for some interesting command to
feature in this COW, we ran across an odd item.
DIR stands for Directory, more commonly known today as the File Folder. So as one would expect, the DIR command produces a list of the names of files in the "current" directory or folder. As such it is limited to displaying file names in the GHS screen display area. DIR /MACRO:macname takes it a step further. Instead of directly listing each file name, it passes the name to the macro you have provided. This gives you an opportunity to do anything you like. For example, if for some reason you wanted to get the list of file names (nicely alphabetized, by the way) into a file named DIRLIST.TXT, you would do it like this: |
MACRO WRITENAMES
ME "%1
/
ME (REPORT) DIRNAMES.TXT
DIR /MACRO:WRITENAMES
ME (REPORT) OFF
|
A more useful application is to process run files in the folder. It would go something like this if you wanted to run all the files having the .RF extension: |
MACRO MULTIRUN
RUN %1.RF /CALL
/
DIR *.RF /MACRO:MULTIRUN
|
The manual gives an example in which backup copies are made of all the geometry files having .GF extensions. It also illustrates that you can pass explicit parameters to the macro ahead of the one added by DIR /MACRO: |
MACRO COPYBAK
COPY "%2.%1" "%2.BAK"
/
DIR *.GF /MACRO:COPYBAK GF
|
It's amazing what odd things you find in the GHS manual. |
Questions, comments, or requests?
Contact Creative Systems, Inc. USA phone: 360-385-6212 Fax: 360-385-6213 Office hours: 7:00 am - 4:00 pm Pacific Time, Monday - Friday Mailing address: PO Box 1910 Port Townsend, WA 98368 USA Click here for an index to this and previous COWs |