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

ME REPSTART & REPEND

These days, you might be finding time to re-watch some of your old favorites. But when you're knocking out a whole season of that old show in a weekend, you might start to grow weary. Wouldn't it be nice to enjoy spring on a trail somewhere? Oh the anguish.

But luckily there's always the sandbox that is GHS. And when all you have is time, there's one GHS topic that will surely use every minute of it.

The MESSAGE command has been featured in many past COWs, including these three on custom plotting COW010, COW110, COW135, this one on ME SEND COW049, and this one about plan and profile graphics in the plot area COW150, but we've never discussed in detail how it can be used in custom tables and reporting.

As most of you know, the basic form of "custom reporting" is using simple NOTE commands to send text and variable definitions to the report file. If you're using classic report formatting (i.e. the default monospaced report style in GHS) this works well enough for most output, and tables can be formatted by counting character widths and conforming to the following guidelines:

    • Variables without spaces inside the curly braces can not be justified. This format is useful to place the variable value in a sentence.
    • For tables, we need a way to justify the variable contents within a specified column width. You can control the justification of the contents by placing spaces inside the curly brackets. If the space(s) are on the left, the value is right justified; if on the right, the value is left justified; if on both sides, the value is centered.
    • When a variable is justified, the variable field is allotted a number of characters equal to the total characters between, and including, the curly braces. For example, { R234}, reserves 7 characters for the value of variable R234.
    • Any attempts at justification are invalid if the contents of the variable is larger than the allotted space.

If you follow these guidelines, you can create some very respectable report output, including tables, parameter summaries, and notes.

But with all of this extra time you've decided you'd like to add some artistry to your reports, and that requires color, and font options, and text styles, so simple NOTE commands are no longer going to cut it. It sounds like you've moved from black and white to color, and subsequently discovered REPORT /BOX:COLOR, the "fancy" report style.

To capture this new-found fanciness, you'll have to wrap your NOTEs with ME REPSTART and ME REPEND. All other report content must go between these two markers:

print configure /font:"Times New Roman"

report /box:color
me repstart
\-------------Example Table--------------\
\                       C O L U M N S    \
\----Col1----Col2----Col3----Col4----Col5\
me repheader
\----(m.)----(m.)----(MT)----(MT)----(MT)\
\ { a1:2} { a2:2} { a3:2} { a4:2} { a5:2}\
\ { a2:2} { a3:2} { a4:2} { a5:2} { a1:2}\
\ { a3:2} { a4:2} { a5:2} { a1:2} { a2:2}\
\Sum of last column-------------->{ as:2}\
\--------------This footer is an example.\
\ `blank line
\Here we put extra info, such as notes.\
me repend
report close /preview

...which creates the following technicolor masterpiece:


You'll notice GHS automatically picks up the first line as a title, the second as a top-level header line, and the third as a column header line, but for the fourth we have to specify ME REPHEADER before creating the line. This is because GHS assumes only a single column header line is needed, and would otherwise treat any following lines as data lines. Here we added a unit line, so we had to override the default behavior. These overrides exist for other report items, so if things get really exciting, you might want to take a look at HELP ME. Also notice that ME REPSTART and ME REPEND respect any PRINT CONFIGURE /FONT settings.

Here are a few more tips to ensure success when you start building your custom fancy reports:

    • Layout the column widths for your table first. There is no real advantage to spaces between variables in a table, so listing variables back-to-back, i.e.
      \{ a}{ b}\, gives you more characters within each column.
    • Copy the table header line(s) above the data line to align the two when designing your table, then move the header line(s) back to their original location in the run file. Unlike the above example, they are often not in the same location in the run file typically because the data lines are in an iterative macro and the header only prints once.
    • Use a text editor which displays the column number.
    • If you make changes to a data line, save a copy of the original so you can compare the spacing and change the header according the column shifts. Adding decimal control will add two characters to your column because ":n" makes the variable name longer by 2.
    • Mapping user variables to 1-letter variables used only for row printing is helpful for making columns narrower. The minimum number of characters in a right-justified column is 4 { a}. If decimal control is used, then it jumps to 6 { a:n}. The decimal control can be performed when defining the print variables to get back to 4. For example, SET a={longVarName:2}.

We'll hand it to you, those proportional fonts do look nice, but there's still one thing that proportional fonts will never do well:


Here's the run file that made this animation.

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