GHS Port Reference Center
Information for maritime designers, engineers and builders
Maintained by Creative Systems, Inc., Creators of GHS
Click here for information about GHS and other fine marine software.
Go to Main page

Example Wizard File for an inclining. NOTE: There is also a wizard within GHS.
    save temp.old
    write (macros) temp.mac
    clear macros
    clear variables
    report off
    page 1
    
    variable spgr0,spgr1:1:1.1
    variable q,h:-10:10,d1,l1,d2,l2,d3,l3,d4,l4,d5,l5,d6,l6,d7,l7
    variable gmtmmt,repmode,cleared
    variable (string) self,proj,size,note:0:78,t
    variable (string) fa1,sd1,fa2,sd2,fa3,sd3,fa4,sd4,fa5,sd5,fa6,sd6,fa7,sd7
    set size="small"
    set repmode=0, cleared=0
    set proj="INCLINE"
    
    set self="INCLINE.RF"
    
    template about "About this wizard"
     "If this is the first time you have run this wizard in the present"
     "working directory, your present geometry and loading condition, if"
     "any, will be used as the starting point.  You can then make any"
     "adjustments necessary to represent tank conditions and other loads"
     "existing at inclining that are to be separate from light ship."
     ""
     "However YOU MUST ENTER DRAFTS even if you have specified drafts"
     "prior to running this wizard."
     ""
     "Depending on whether you have done SOLVE or LIGHT SHIP last before"
     "pressing Ok, the as-inclined condition or the light ship condition"
     "will be saved as a run file named {proj}.sav.  It will also include all"
     "of the settings (drafts, etc.) and it is autometically run the next"
     "time you run this wizard so that you will not need to reenter the"
     "settings."
     ""
     "But if you exit the wizard dialog through the Cancel button, your"
     "original condition gets restored."
     ""
     "The fixed weights and tank loads present at inclining (weights to subtract)"
     "are saved in a run file named {proj}.cnd."
     ""
     "Any weights to be added into light ship (weights to add) are saved in"
     "{proj}.add."
     ""
     "This wizard is itself a run file that defines its own macros.  In order"
     "to avoid overwriting macros by the same names that you may have"
     "defined it saves your macros and restores them before it ends."
    /
    
    macro defaults
     set spgr0=1.025
     if "{sea}"<>"" then set spgr0={sea}
     if "{spgr1}"="" then set spgr1={spgr0}
     if "{fa1}"<>"" then exit
     set fa1=%1
     set fa2=%1
     set fa3=%1
     set fa4=%1
     set fa5=%1
     set fa6=%1
     set fa7=%1
    /
    
    macro readsave
     run {proj}.sav /call
     cls
    /
    
    macro save
     report off
     save {proj}.sav
    /
    
    macro unload
     delete all weights
     load (*) 0
    /
    
    macro getcnd
     macro case
     `noop
     //
     macro t
       if fexist %%91 then run %%91 /call
     //
     .t {proj}.cnd
     cls
    /
    
    macro delcnd
     macro t
      if fexist %%91 then erase %%91
     //
     .t {proj}.cnd
    /
    
    macro clear
     template t "Warning"
      "Are you sure you want to clear all inclining settings?"
      "Yes" "No" exit
     //
     .t
     if {templok}=0 then exit incline
     .delcnd
     .t {proj}.sav
     .t {proj}.add
     set cleared=1
     template t " "
      "Please rerun this wizard to begin fresh."
      "Ok" exit
     //
     .t
    /
    
    macro savecnd
     .delcnd
     write (loads) {proj}.cnd
    /
    
    macro saveadd
     write (fixed) {proj}.add
    /
    
    macro getadd
     macro t
       if fexist %%91 then run %%91 /call
     //
     .t {proj}.add
    /
    
    macro drstr
     set sd%1=""
     if "{d%1}"="" then exit
     if "{l%1}"="" then exit
     set q={l%1}
     if "{fa%1}"="FWD" then set q=minus {q}
     set sd%1="{d%1}@{q}"
     set t="ok"
    /
    
    macro setwpl
     set t=""
     heel {h}
     .drstr 1
     .drstr 2
     .drstr 3
     .drstr 4
     .drstr 5
     .drstr 6
     if "{t}"="" then depth=0 | exit
     set error=-1
     draft {sd1} {sd2} {sd3} {sd4} {sd5} {sd6}
     template t "Warning"
      "Faulty draft specification:"
      "  {sd1} {sd2} {sd3} {sd4} {sd5} {sd6}"
     //
     if {error}<>-1 then .t
     set error=0
    /
    
    macro le
     .setwpl
     fix depth
     load edit
     vary depth
    /
    
    macro scrstat
     stat fixed:br tanks:br wpl:total /fsm
    /
    
    macro repstat
     page
     load (*) status
     page
     stat ghs
    /
    
    macro stat
     if {repmode}=0 then .scrstat else .repstat
    /
    
    macro wts
     .getcnd
     tanks off
     .le
     .savecnd
     cls
     st fixed:brief
    /
    
    macro tks
     .getcnd
     tanks *
     .le
     .savecnd
     cls
     st tanks:brief
    /
    
    macro cg
     display (*) status
    /
    
    macro checkval
     if "%1"="" then set t="missing" | exit
     if %1<%2 then set t="too small" | exit
     if %1>%3 then set t="too large" | exit
     set t=""
    /
    
    macro solve
     template t "Error"
      "GMT Moment is {t}"
     //
     .checkval "{gmtmmt}" 0.001 999999 | if "{t}"<>"" then .t | exit
     .getcnd
     cls
     .setwpl
     water {spgr1}
     gmtmmt {gmtmmt}
     .stat
     .savecnd
     template t "Note" /pos:bottom
      "The as-inclined condition is shown above."
      "CG" exit .cg | "<-- Press here for the Condition Graphic"
      "Ok" exit
     //
     if {repmode}=0 then .t
    /
    
    macro report
     cls
     template t "Note to be included on first page of report "
      note
      "Ok" exit
     //
     .t
     page 1
     subtitle
     \Inclining Report\
     report {proj}.pf
     \\\\\\
     \{note}\
     \\\\
     set repmode=1
     .solve
     .ltship
     set repmode=0
     view
     report off
     template t "Note"
      "You can print this report through the Report pulldown menu."
      "The report file name is {proj}.pf"
      "Ok" EXIT
     //
     .t
    /
    
    macro add
     .unload
     .getadd
     tanks off
     .le
     .saveadd
    /
    
    macro ltstat1
     page
     \WEIGHTS INCLUDED IN LIGHT SHIP\
     stat weight, displ
    /
    
    macro ltstat2
     if {repmode}<>0 then page else cls
     \LIGHT SHIP\
     stat weight, displ
     template t "Light Ship"
      "This is the light ship condition with the added weights included."
     //
     if {repmode}=0 then .t
    /
    
    macro ltship
     .unload
     .getadd
     template t "Error"
      "Drafts missing or too small."
     //
     if {fweight}<0.01 then .t | exit
     heel 0
     trim 0
     water {spgr0}
     solve
     if {repmode}<>0 then .ltstat1
     weight *
     .ltstat2
    /
    
    macro readgf
     template t "Note"
      "No geometry file has been read."
      "Do you want to locate and Read one now?"
      "Yes" "No" exit
     //
     .t
     if {templok}=0 then exit
     template t "Geometry file"
      "Read" file t /ext:"gf" /exist
     //
     .t
     if {templok}=0 then exit
     read {t}
    /
    
    template whatgmt
     "GMT moment is the inclining moment / angle (radians)."
     "This is the slope of the line of plotted inclining moment vs. angle,"
     "or inclining weight x distance moved / tangent (angle)."
    /
    
    macro incline
    template t2 "Inclining Wizard" /pos:bottom %1
     ""                             | ""               | ""   | "About" .about | "Resize" exit resize
     ""                             | ""               | ""   | "Clear" exit clear
     "Specific gravity"                spgr1
     "Heel angle"                      h
     "Average (port & stbd) drafts at longitudinal locations:"
     "Draft 1"                         d1              | "@ location 1"     l1 | "FWD" "AFT" fa1
     "Draft 2"                         d2              | "@ location 2"     l2 | "FWD" "AFT" fa2
     "Draft 3"                         d3              | "@ location 3"     l3 | "FWD" "AFT" fa3
     "Draft 4"                         d4              | "@ location 4"     l4 | "FWD" "AFT" fa4
     "Draft 5"                         d5              | "@ location 5"     l5 | "FWD" "AFT" fa5
     "Draft 6"                         d6              | "@ location 6"     l6 | "FWD" "AFT" fa6
     "Draft 7"                         d7              | "@ location 7"     l7 | "FWD" "AFT" fa7
     "Weights to subtract (present at inclining but not in light ship):"
     ""                             | "Weights" .wts   | "(fixed)"
     ""                             | "Tanks"   .tks
     "GMT moment"                      gmtmmt          | "?" .whatgmt
     ""                             | "Solve"   .solve
     "Weights to add (not present at inclining but to be included in light ship):"
     ""                             | "Add"     .add
     ""                             | "Light Ship"  .ltship
     ""                             | "Report"  .report
     "Ok" "Cancel" EXIT
    //
    exit t2
    /
    
    macro dialog
     if {size}="default" then exit incline
     exit incline "/size:{size}"
    /
    
    macro resize
     template t "Resize dialog box"
      "default" "small" "medium" "large" size
      "Continue" EXIT
     //
     .t
     exit dialog
    /
    
    macro doincl
     screen nohead
     me inclining wizard\
     .dialog
     if {templok}=0 then exit
     if {cleared}<>0 then exit
     .save
    /
    
    macro init
     set h=0
    /
    
    macro esc
     template t "Error"
      "Error encountered in running {proj}.sav."
      "Restart" "Exit" EXIT
     //
     macro recover
      set error=0
      erase {proj}.sav
      run {self}
     //
     .t
     if {templok}<>0 then exit recover
    /
    if fexist {proj}.sav then .readsave /call else .init
    macro esc
    /
    if "{gf}"="" then .readgf
    set t="AFT"
    if lunit="METERS" then set t="FWD" `origin is probably aft if meters
    .defaults {t}
    
    if "{gf}"<>"" then .doincl
    
    clear macros
    clear variables
    macro restore
     run temp.old /call
     template t "Note"
      "Original condition restored."
     //
     .t
    /
    if {templok}=0 then .restore
    macro restore
    /
    run temp.mac /call
    scr head
    erase temp.mac
    erase temp.old
    
Add a free link to your site
Copyright © , Creative Systems, Inc.
Privacy policy