General HydroStatics
Ship Stability Software
Command of the Week
(New or interesting aspects of GHS that you may not know about)

Functions are convenient
(Requires GHS version 17.36 or later )

Since last week's article approached the length of an epic poem, this COW will be especially short and sweet.

Inspiration comes from a recent customer inquiry who wanted help loading tanks by the gallon in his run file. This diligent customer had already checked for options in HELP and correctly concluded that LOAD only accepts volumes in cubic length units (either feet or meters). Rather than give up, he reached out to us for ideas.

We sent back the following snippet of code that he could use.
  macro gal2ft3 /fun
    gal2ft3:=%1*0.13368056
  /
  load (hold1.c) vol:{gal2ft3(1100)}

Using a function to convert gallons to cubic feet instead of normal macro allows the resulting LOAD command to be largely unchanged except that the volume specified is an expression with a function inside it. Given the name, there is a good chance future readers will understand the function's purpose without even looking at its contents.

Could you have done something similar with a regular macro using parameters to pass the tank name and number of gallons to the load command? Sure, but who would read a COW about that‽

In case you are wondering, the STATUS command already offers options to display tank volumes in any of the following units:
   GA - gallons;
   IM - imperial gallons (synonyms: IG, GI);
   CF - cubic feet;
   CY - cubic yards (synonym: YD);
   CM - cubic meters;
   LI - liters;
   BB - 42-gallon barrels.

For this example, either of the STATUS commands below would be fitting.
  STATUS TANKS /VOL:GA
  STATUS TANKS /ADDVOL:GA



Questions, comments, or requests?
Contact Creative Systems, Inc.

support@ghsport.com

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

www.ghsport.com

Click here for an index to this and previous COWs