Template Command Tutorial      

1. Introduction    2. Basic Template Structure    3. Variables, Fields, and Run Files    4. Example Run File   

Maintained by Creative Systems, Inc.,Creators of GHS.    Click here for information about GHS and other fine marine software.



Template Command Tutorial: Page III


Introducing Variables, Multiple Fields, and Run File Integration.

For this portion of the tutorial we are writing a run file that will define a template to set variables for creating a tank. Then the run file will read a geometry file, create a tank, and write a geometry file based on those variables.

The first step is establishing which variables we need to declare. We are creating a tank, so we declare variables for: the geometry file (INGF), the name of the tank part (TNKP), the component (TNKC), the side designation (TNKS), the ends (TEND1)(TEND2), the inboard (NBD), the outboard (TOUT), top (TOP), and the bottom (TBOTT) locations of the tank.

Here is the declaration:

VARI (STR) INGF,TNKC,TNKP,TNKS
VARI TEND1,TEND2,TOUT,TOP,TBOTT,NBD

Once we have the variables declared we can assign values to them and use them as parameters:

VARI (STR) INGF,TNKC,TNKP,TNKS
VARI TEND1,TEND2,TOUT,TOP,TBOTT,NBD

READ {INGF}.GF
ENTER PM
CREATE {TNKP}\{TNKC}{TNKS}
ENDS {TEND1},{TEND2}
INBOARD {NBD}
OUTBOARD {TOUT}
TOP {TOP}
BOTTOM {TBOTT}
/

WRITE {INGF}1.GF
QUIT

END


This run file gives us an opportunity to write a template for the purpose of assigning data to each of these variables.

The template we are going to write is called TNKMKR. The description listed on the title bar will read: "Tank making dialogue." Our initial command line will be:

TEMPLATE TNKMKR "Tank making dialogue."

The second line starts the TEMPLATE body. Each new line in a command's body denotes a new line in the template unless the previous line ends in a comma. Each line is made up of fields separated by a '|' symbol (called a pipe).

The first line is a single template field surrounded by quotes.

"This run file will create a tank using Part Maker."

The BREAK statement is used to reset field size and alignment within the dialogue box. You can also create a visual horizontal split by using the LINE parameter with the BREAK statement. We are doing this to aesthetically separate our generalized description from the input areas we create.

BREAK LINE

After the line break, we want to have some

"label" VARIable

Although both a label and variable usually reside on the same line and field, either could conceivably make up a field or line by itself. To illustrate this, we are placing the dialogue on one line, and the variable on the next line:

"Enter the hull geometry file name (Do not include .gf extension):"
INGF

This is what your template will now looks like:



The next field asks for a tank name. The first line is a text-only line that will say, "Please enter the tank name:" The next line will utilize three fields: two variable input fields for the Part and Component names of the tank, and one drop down box with three options for the side designation.

"Part: "TNKP|"Component: "TNKC|"Side:"|"centerline":".c","starboard":".s","port":".p"TNKS

The side designation will have one dialogue label stating "Side", three variable labels (centerline, starboard, or port), and three values (.c,.s,.p) to optionally set to the variable TNKS. Each "label"[:value] will be separated by a comma. After the last value, the variable is listed. Note the '|' separating each field in the syntax for this line:

Here is the run file and template to this point:

VARI (STR) INGF,TNKC,TNKP,TNKS
VARI TEND1,TEND2,TOUT,TOP,TBOTT,NBD

TEMPLATE TNKMKR "Tank making dialogue."
"This template will create a tank using Part Maker."
BREAK LINE
"Enter the geometry file you wish to modify (Do not include .gf* suffix):"
INGF
"Please enter the tank name:"
"Part: "TNKP|"Component:"TNKC|"Side:"|"centerline":".c","starboard":".s","port":".p"TNKS
/

.TNKMKR

END




The rest of the commands needed for this template follows what we have already learned. The template below shows what the finished template looks like. Try to write the rest of the TEMPLATE command on your own.



Template Command Tutorial: Page VI

1. Introduction    2. Basic Template Structure    3. Variables, Fields, and Run Files    4. Example Run File   

Customer Support

Copyright (C) 2011, Creative Systems, Inc.