Professional Documents
Culture Documents
2
General Tools and Functions
Table of Contents
1 General Service Functions and Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Functions of group MN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Information related to the current run. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.2 Project administration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.3 Run-time error functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.4 Various. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.5 Program and user information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.6 Printing. macros, lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.7 Licenses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Events of group MN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Functions of group AD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3.1 Functions related to quantities and units. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.2 Standard syntaxes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.3 Functions treating LQ,PQ,TOO,POO. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.4 Check and information of data items. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.5 Arguments, report control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.6 Various. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.7 String functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.8 Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.9 Functions related to the reference system. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.10 Functions related to process tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Functions of group DB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4.1 Function related to objects in the data base. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4.2 Functions related to file management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4.3 Functions related to files in general. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4.4 Functions related to data access and security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4.5 Various. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 Functions of group DM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5.1 Operations with descriptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5.2 Operations with arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5.3 Various. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 Functions of group AI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.7 Events of group AI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.8 Functions of group AP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.9 Events of group AP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.10 Functions of the group OS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.10.1 Dynamic memory functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.10.2 File I/O functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.10.3 Other functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 User Profile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.1 What is the User Profile?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.1 Widgets and widget names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.2 Resources and resource settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 Resource files and User Profiles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.3 Useful resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3.1 NAPADB resource files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3.2 Key bindings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Calculator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.2 Run time information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.3 Purpose. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.4 Basic concepts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.5 Variables and arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.6 Logical expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.7 Handling of functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.8 Subsystem service functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.9 Summary of functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.9.1 Mathematical functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.2 Logical functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.3 Date functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.4 String handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.5 Data management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.6 Volume oriented functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.7 Functions for curves and surfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.8 Functions related to the arrangement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.9 Various functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.10 Support functions for the calculator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.11 Functions operating on arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.12 Functions available under table calculation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.9.13 For container loading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.10 Parameterless functions and constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.11 Multiply defined symbols. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.12 Detailed presentation of functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.12.1 Mathematical functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.12.2 Logical functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.12.3 Date functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.12.4 String handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.12.5 Various functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.12.6 Data management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.12.7 Functions related to objects with a volume. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.12.8 Functions for surfaces and surface objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.12.9 Functions related to arrangements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.12.10 Intersecting an object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.12.11 Functions operating on curves. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.12.12 Functions operating on arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.13 Handling of upper case and lower case. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.14 Current source description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
1.1.4 Various
1.1.7 Licenses
1.3.6 Various
1.3.8 Database
1.4.5 Various
1.5.3 Various
2.1 General
The components of the graphical user interface are implemented using Motif, which in turn is based on the
Xwindows system. In the PC world, where Xwindows is not part of the standard operating system, an emulator
such as EXCEED is needed.
The graphical user interface forms a layer of control on the main NAPA. In most cases, commands and control
from graphical user interface can be mixed.
The NAPA macro language forms the common tool by which all functions are controlled: both the actions within
the graphical user interface and the actions by the main NAPA.
The main form of communication between the macros and the functions being controlled is the service
functions. These handle communication both ways: asking for information and executing control. The control
may also be achieved by normal commands.
Communication from the main NAPA to the graphical user interface is also handled by NAPA events: an event
is a specified change of state, for example, table value changed, to which an action can be attached. The
action is implemented by a macro.
2.2 Widgets
The graphical user interface is based on a set of objects called widgets. These may or may not have
components visible on the screen. The widgets receive the user actions as events which may trigger callback
for carrying out some action. For creating widgets, the widget editor is provided.
2.4.3 Miscellaneous
2.4.4 Internal
3 User Profile
When NAPA is started, the user has the option of specifying a User Profile. This document describes what
the User Profile is and it explains more about the graphical user interface (GUI) in NAPA. The intention is to
provide enough information for the average user, as opposed to the NAPA system administrator, to exploit the
capabilities of the tools for customizing the GUI.
Please note that the construction of a user interface using the Widget Editor or user interface commands (i.e.
those that begin with two exclamation marks) is outside of the scope of this chapter. The focus herein is on the
User Profile only. However, some discussion about widgets and resources is necessary in order to understand
what the User Profile really is.
In this case, we will now be referring to ALL widgets which have the components napa, Toolbar and Draw
in their names, in this order. This wildcard * replaces all the other name components. In the case given above,
the name napa*ToolBar*Draw will also refer to, among others:
■ the Draw button in any Hull Surface Editor window
■ the Draw button in the Ship Model window
■ the Draw button in any Body Plan window
The hard bindings (specified with a period in the name) are used to avoid this effect.
Save the User Profile in the System database by specifying the 'Objects of Type' to be Resource Specs and
then name it your default username
As seen in the example, the specification of a resource setting is done using the name of the widget, followed
by a period or an asterisk, the name of the resource, a colon and then the value of the resource.
The user profile can be saved in the SYSDB with whatever name the user desires. When you want the resource
specifications stored in the particular user profile to be used in NAPA, you type the name of the profile (without
the RES* prefix) into the User Profile field in the login screen. To automatically load your default user profile,
save it with your username in the System database. NAPA by default looks for the user profile saved with the
login name given if no other user profile is specified.
In addition to specifying individual resource settings in the user profile, other resource files can be referred to
by using the !ADD command. This can be seen in the example above where the resource file SMALLLAYOUT
in the NAPADB is added at the end of the user profile.
Comments can be included in a resource specification file by using an exclamation mark (!) in the first column
of a line, followed by a space.
Note that the spacing included between the end of the resource name and the setting is for stylistic purposes
only. Also note that a more specific resource specification always has precedent over a less specific one. For
instance, in the example above, while the background in NAPA for ALL windows has been set to Beige, the
more specific setting of the Loading Conditions window's background to Light Blue takes precedence. The
same is true for the showing of the command area. In all windows in NAPA, the command area will be visible
when the window is opened, except for the Loading Conditions window where it will be closed (as the setting
is "false").
When starting NAPA, the resources are controlled by the resource specification file RES*SYSTEM in the
NAPADB. This controls the layouts, fonts, colors, key bindings, etc. It is not recommended to copy this
resource specification into the SYSDB as such if you wish to modify it. Write a new one with only
the changed resources and an !ADD statement referring to the one in the NAPADB. This way also new
releases of NAPA will have a chance to work.
Resource specifications and user profiles have some use, mostly as visual aids and to modify settings in
particular windows in order to eliminate routine settings whenever a window is opened. Some possible uses
for user profile settings are:
■ setting of different background colours for different runs of NAPA on the same computer. This helps to
identify which run or project you are using if you have a lot of windows open on your screen
■ using different backgrounds for different windows in the same run of NAPA, as a visual aid
■ using larger layouts and fonts for presentations
■ using smaller layouts for more complicated windows in NAPA, for example, Ship Model window, NAPA
Steel window
■ automatic opening of the command area in a window when it is open
■ automatic setting of totals for tables opened in various windows
Colours used in resource specifications can be viewed using the standard Select Colour dialog. It can be seen,
for example, by opening the Geometry Window, choosing Background from the View menu. Then select
and the Select Colour dialog will appear. The names of the colours that can be used in resource specifications
can be seen by selecting a colour.
Note: widget and resource names are case sensitive. Values for resources are not.
Colors, margin settings and fonts are not listed in detail here, as the appropriate names and possible settings
can be seen from the files listed in the next sub-section below.
The settings for other windows for some of the resources above (when they occur) can be specified separately
using the following widget names (not the Widget Collection name) immediately after the component "napa*"
or in place of the component "MainW", depending on what is given above.
List of main window names
Widget Name Window Widget Collection Name
TxtEdit Text Editor Window MN_TEXTEDITOR
TabEdit Table Editor TP_TABLEEDITOR
StpEdit Setup Editor DR_SETUPEDITOR
GME_HullEdtr Hull Surface Editor GME_HULL_EDITOR
WgtEdit Widget Editor UI_WIDGETEDITOR
GR_PltWn Geometry Window GR_GEOMWINDOW
GR_PltWn Plot Window GR_TEMPLATEWINDOW
ListWn List Window MN_LISTWIN
Manager Manager MN_MANAGER
Explorer Explorer MN_EXPLORER
HD_Quick Object Info HYD_QUICK
Gr_PltWn Body Plan Window GR_BODY_PLAN_WIN
VarDef Vardef Editor AD_VARED
SM_MW Ship Model Window MW_SM
ST_MW NAPA Steel MW_ST
Note: the Widget Collection name is usable as the SOURCE TOOL in the Manager. See the chapter
Manager in the NAPA Monitor Manual.
Note: a lot of the resources used in various windows in NAPA are stored in resource specification files in
the NAPADB. IT IS VERY STRONGLY DISCOURAGED TO MODIFY ANY FILES OTHER THAN THOSE
LISTED IMMEDIATELY ABOVE! The reason is that there are a lot of widgets used in NAPA and there
are a lot of resource settings. More importantly, a lot of these resource settings are inherited. Without a
full knowledge of what resource settings take effect in what windows, there is no way you can tell
what will happen when you modify a resource setting in the NAPA database. Modification of resource
settings in the resource specification files in the NAPADB can have undesirable consequences and some
NAPA GUI elements may cease to function until the files have been restored to their original state. However,
some of these resource files are useful for reference purposes in creating your own user profiles. Those
dealing with fonts (RES*sizeFONTS) are particularly helpful when you wish to modify font settings in your
own user profile file.
It is recommended that you modify only those resources given in the list of useful resources above and the
resource files mentioned in this chapter. It is anticipated that this list will be expanded in the future as more
examples of useful resource settings become apparent and the GUI is expanded.
Default values for colours are set in the resource specification file RES*COLOURS in the NAPADB. If you
wish to modify the colours, use your own resource file rather than modify this one. Fonts are controlled by the
resource files RES*sizeFONTS and RES*sizeFONTS2 listed in the table above and follow standard syntaxes
for font control in Motif.
■ These key bindings are available only in the command area of the NAPA Main Window, but definitions
can also be effective for one widget class in all widgets, as in the RES*SYSTEM definition in the
NAPADB.
3.4 Example
The two resource files below illustrate some of the things that happen when using resource settings and user
profiles. These user profiles are available in the NAPADB.
Note: the example illustrates the following point: resources which have been set beforehand are maintained
unless they are changed. In this case, for example, the background colour and the size of the command
area in the EXAMPLE2 login have been maintained from the setting in the EXAMPLE user profile.
4 Calculator
4.1 Introduction
It has become more and more important to be able to do things not programmed in the compiled system code.
Conventional programming is too inefficient for covering the wide range of local needs encountered, the cycle
from identifying a new need to implementing is too long and end users have no possibilities to do their own
things this way.
The graphical user interface has created a new area where flexible programming of system functions is needed.
Implementing new functions without touching the FORTRAN or C code is possible by the following two main
services:
■ the calculator, which provides not only various calculations in the conventional sense, but also the
possibility to make decisions, access data in the system and start system functions
■ the so-called NAPA BASIC, providing a control structure by which the pieces can be combined into larger
functions
A concept closely related to these is the event, which is a way of starting macros, as presented in the chapter
Handling input.
This chapter presents the calculator. The calculator is a tool for doing calculations according to user-defined
expressions and formulas. The possibilities range from ordinary mathematical calculations to calculations
involving geometric and other objects as illustrated by the following examples (the length, the area of a section,
the volume from a gauge reading):
!CALC
L=SQRT(DX*DX+DY*DY+DZ*DZ)
!CALC A=AREA(SECT('HULL',1,XREF))
!CALC V=CP.GVOL('R123','MS',2.25)
The calculator can be used as such in command !CALC, in order to evaluate expressions and assign variables,
it provides the basic mechanism for expressing calculation logic in the table calculation module, it can generate
derived data in list output and above all, it provides the power to add intelligence and flexibility to macros.
An important part of the functions is formed by the so-called subsystem service functions. These functions are
treated as part of the user interface to the subsystem concerned and provide ways of accessing data in macros
and new ways of starting functions. Compared with the command interface, the service functions provide a
two-way communication with macros and they are not restricted to be used in a specific command environment
(subtask). The value returned by many service functions is an empty string: the main result is formed by actions
started or data returned some other way.
A macro where the possibilities offered by the calculator are used is often referred to as a NAPA BASIC
program, because of many similarities with real BASIC. In addition to ordinary NAPA commands, such a macro
can contain components replaced by variables or expressions, and program statements for handling decisions
and jumps. A macro containing nothing but NAPA BASIC commands can be run in the so-called immediate
mode.
For sophisticated use of the calculator, involving direct access to data items in the database, read the section
Short introduction to data management in the System document.
Most of the information presented here is not needed in the daily work, only when preparing macros and other
tools. However, even for direct use in the routine work there are many useful functions available.
Examples:
!COM GR.F: list of functions provided by GR
!EXP GR.COLOUR: use of the function GR.COLOUR
!COM C.F: list of standard calculator functions
!EXP C.WLPOS: explanation for the function WLPOS
!COM B.F: list of NAPA BASIC commands
4.3 Purpose
The calculator is a tool by which a variety of tasks involving fetching and combining of data can be done with
user commands.
The basic function of the calculator is to evaluate an expression containing arithmetic and logical operations on
operands that can be constants, variables or function values. In addition to the usual mathematical functions
(SQRT,SIN, etc), the functions of the calculator cover a wide range of other operations, including pure NAPA
operations such as finding coordinates on curves, parameters of a compartment or fetching data from the
database.
The calculator operations are available in a variety of ways:
■ directly accessible in command !CALC
■ in column and other definitions of the table calculation module
■ extending the standard set of quantities in table output (command LQ)
■ substituting fixed components by variables and expressions in macros
■ providing logic for decisions in macros
■ providing additional flexibility in various other functions
The basic function of a calculator function is to return a value. However, in an increasing number of functions,
mainly among the service functions, the main result is not the function value, which is often empty, but the
actions started.
A built-in constant resembles otherwise a variable, but its value is provided directly by the calculator.
■ quantity
The symbol of a quantity, as defined in the quantity standard, designates the value of the given quantity.
This is possible only in contexts where there is source of such values defined (table output module, SH
based subsystems).
Note: in case of name conflicts, a symbol is interpreted as a variable in the first place.
Examples of expressions:
2+5
(10-8)*5
SQRT(2)
SIN(FI*RO)
ATAN((10-8)/(7-2))
VOL(HULL)/(LREF*ZDWL*BREF)
In the same way as in NAPA commands, the calculator makes a distinction between numbers and strings. The
type of a constant, variable or expression must be correct in the context where used. The functions FMT and
VALUE can be used for converting between the types. In the same way as many parameters of commands,
there are function parameters that can be either a number or a string, but with different meaning.
Note also carefully the difference between a string constant (entered within apostrophes) and a variable name.
Each call of the ARR function without an identifier creates a new array in the run time memory and it is possible
that a significant amount of garbage is collected. This can be avoided by using the identifier or by having a
local variable receive the result (see commands @LOCAL, @GLOBAL of NAPA BASIC).
An array can be listed with command !VAR LIST name. There are formatting options by which the layout
can be controlled.
The value of an array element is obtained by the adding an index in parentheses after the array name, for
example:
A(2), X(I)
If the array contains reals, a non-integer index can be given, giving an interpolated value. For example, if
A(1)=4, A(2)=5, then A(1.25)=4.25.
A calculator symbol may also refer to a description, i.e. a packet of data as handled by the data management.
Variables referring to arrays or descriptions are so-called reference numbers and marked as being of a
different type with respect to ordinary numbers, and this type is checked when interpreting array references. If
for some reason the array property is lost, the calculator can be restored by using the ARR function, for example
@A=ARR(A)
One case when this is needed is when a list of arrays has been created, for example
@ARRLIST=ARR(1)
@ARRLIST(1)=... some array
...
@A1=ARR(ARRLIST(1))
Reference numbers are not meaningful in arithmetic expressions or logical expressions except when testing
for existence (>0):
@C=DB.READ('STEM')
@IF C=0 !TYPE STEM not found
More complicated decisions are handled by the logical functions AND, OR and NOT.
The result of the logical operations is the numbers 0=false or 1=true. This result is in all respects treated like
any other numbers, and it can be used in arithmetic operations. Conversely, any number can be used as a
logical value, where >0 means true and <=0 means false.
Variables representing reference numbers (arrays, descriptions) behave like numbers in comparisons, but the
only meaningful tests are 'equal' or 'not equal'. The only meaningful numeric constant is 0 which means that
the component in question is missing.
Examples. It is supposed that the values of the variables are A=3, B=4 and S='HULLF'
A>B -> 0 (false)
Note: an expression of the form x(y) may stand for a function, an array reference or the value of a quantity
in the current source description (see below), and these possibilities are tested in this order. A common
source of confusion is name ambiguities between these categories. Command !VAR CHECK tells whether
there are multiply defined symbols. !VAR CHECK ON sets a check mode when all possible ambiguities are
tested every time a symbol is referenced.
where ss is the subsystem name, e.g. GM, SM, MN, 'funct' is the name of the function in question. This part is
always followed by a pair of parentheses even if the parameter list is empty. The only way to create a synonym
is to name an array according to the form above. Then a reference to an array element looks like a subsystem
service function. A warning is given when the array is created but otherwise this possibility is ignored in checks
related to multiply defined symbols.
The availability of service functions varies between subsystems, partly depending on the order in which the
graphical user interface has been developed.
For a list of service functions in a subsystem, use
!COM ss.F
where ss=the subsystem name. For an explanation of a given function use
!EXPL ss.id
for example
!EXPL GR.COLOUR
Within some subsystems, it has been found practical to separate certain functions as own groups, for example,
the functions of the Hull Editor and those of the panel task in GM. The following is a summary of the groups:
The service functions are newer additions and there is some overlap between them and some of the standard
calculator functions, and many standard calculator functions should logically belong to a subsystem such as
GM.
■ CHAR(i): character with ASCII code i. The most frequent need for this function is to represent nonprinting
characters such as CHAR(27)=<esc>. It performs also the reverse functions, e.g. CHAR('A')=65
■ LCASE(string): convert string to lower case. With 1 as the second parameter (e.g. LCASE(NAME,1)) the
first character is returned in upper case. With 2 as the second parameter, the whole string is converted to
upper case.
■ PARSE(string,arr): the parts of the given string (separated by spaces) are added to the array 'arr'. The
function value tells the number of values added. If the array is a numeric one, only those items that can
be converted to numbers are returned.
This function has been added in order to simplify fetching of data from text files (after reading into the
editor work area or into a variable). It can also be used as a convenient way of initializing an array, for
example:
@A=ARR(2)
@PARSE('1 1.2 3.35 4.1 5 6.7 9.2 11',A)
The FMT function needs a closer presentation. Regarding the main parameters of the FMT function, note the
following:
If f (=the field length) is not given, the so-called dynamic format is used, where the result is as long as required
by the given value, and d (=the number of decimals) is only the upper limit, trailing zeros are omitted. If the
field length is given, the result is as long as specified by f, and the number of decimals is the given one.
If both f and d are omitted, a useful format is estimated, unless a quantity has been given.
The options 'unit' and 'qnt' have been added in order to help macros print data in a simple way, still being less
ascetic than just printing bare numbers:
FMT(value,d,f,unit,qnt)
'unit' causes the symbol to be added and the unit conversion to be done, for example,
FMT(1.24,'CM') -> 124 cm
'qnt' tells the quantity and it is used as a label. A format or unit not given separately is fetched from the quantity
standard. Example:
FMT(DISP,2,8,'DISP') ->
DISP = 4557.81 ton
FMT(6546,'MCT') -> MCT = 65.4 tonm/cm
With an asterisk added, the long header is fetched from the quantity standard:
FMT(DISP,'*DISP') -> displacement 4557.8 ton
The unit can be omitted before 'qnt', if the quantity cannot be mistaken for a unit; otherwise, the unit must be
entered as '-' (no unit) or '+' (use standard unit).
For more string handling functions, see service functions of groups AD and OS.
■ QUANTITY(id): fetches a quantity in the SH sense. The value is a reference to the record containing the
quantity: @R=QUANTITY('PB') @R(1)=the first value.
■ FR(x),XFR(frn): frame number from x-coordinate and vice versa
■ DTX(string): return dynamic text. Use command !DTX for list of valid alternatives. For example,
DTX('PRO')=current project.
■ REF(id, qnt): value from the reference system. 'id'=symbol used under task REF for the item, for example,
REF('LOA') gives the total length. With the optional parameter 'qnt', a value associated with the item can
be found, see chapter Reference system (REF).
■ TRAN(text,lang): applies the language translation function on the given text. Parameter 'lang' designates
the language. It can be omitted if the language is set with the command !LANG.
■ RND(range,name): returns a random number (integer) from the given range. Parameter 'name' is
optional, and it has the effect that with the given name and range, the same number is always returned.
■ VTYP(name): tells the type of a character constant (note!). The function value can be
0 not defined
1 numeric variable
2 string variable
11 numeric quantity
12 string quantity
21 numeric array
22 string array
26 description (e.g from DB)
This need may occur if the symbol has obtained its value in a way that does not normally give arrays, for
example:
■ MACRO(name,receiver): get macro using the same identification as in the !ADD command, e.g.
@mac=MACRO('MYPLOT/A'), @MAC=macro('temp>test'). The result is a reference number that can be
used in AI.ADD, AI.RUN. With the optional parameter 'receiver', the result is stored in given string array.
@A=ARRLIST(I)
@A=ARR(A)
■ EVAL(qnt,arg,table): returns the value of the quantity'qnt' (column name) for the given argument
'arg' (value in the key column), as obtained from the given table. For a closer description, see Table
calculation.
■ INPUT(f unit): read the next line from a text file. f-unit is the file unit used when opening the file by
command !OPEN and should be 11...13. The function value is the contents of the line. If the file is ended,
'EOF' is returned and in case of a read error, 'ERR' is returned. Example:
!OPEN TEMP>DEMO 11
!TYPE @INPUT(11)
For manipulating data objects, a more complete set of functions is available as service functions in the groups
DM and DB.
The function WLPOS returns the waterline position, when given volume or center of gravity. The following form
returns the draught, when given volume, trim and heel:
WLPOS(name,volume,trim,heel)
The following form returns the floating position, when given the volume and center of gravity:
WLPOS(name,volume,cgx,cgy,cgz,res)
'res' is an array receiving the result (draught, trim, heel). The draught is also returned as the function value.
Example:
@flpos=arr(2)
@t=wlpos('hull',1000,53,0,5,flpos)
The array FLPOS contains draught, trim and heel as the three first elements.
@c=sect('HULL',1,75)
@a=area(c)
■ INTERS(x1,y1,x2,y2,x,y): intersection between two curves, represented as polygons, stored in the array
pairs x1,y1 and x2,y2. x and y are arrays for receiving the result. The number of points obtained is
returned as the function value. function)
■ INTEGR(x,y, t1,t2): integral of y over x. For the optional parameters t1 and t2, see below.
■ INTERP(x,y,x0, t1,t2): value of the function y at argument x0.
The arrays x and y must be numeric, and in the last three functions, the values must be real (not integer). The
arrays x and y must have the same size.
In the two last functions, x and y are supposed to describe y as a function of x, meaning that y must be single
valued with respect to x. The optional parameters t1,t2 cause a smoothed function to be placed through the
given values, where t1 and t2 are the end derivatives. The dummy value -99 can be used for the derivative,
if smoothing only is desired.
The result of the smoothing can be checked by drawing the function under the diagram drawing task with
the SMOOTH option. The following figure shows the difference when using smoothing, applied on a function
defined by three values. When smoothing is used, the result returned by INTEGR and INTERP is derived from
the curve shown in thin lines; otherwise, it is the thick one.
SOLVE(op,a,b,x)
where op is an integer code as presented below, a, b and x calculator arrays. The matrix A can be given either
as a single array or as a set of arrays, each representing a row or column in the matrix. In the latter case, the
array a is an integer array, containing the reference numbers of the rows or columns.
The parameter op tells whether the matrix is given by rows (op=1) or by columns (op=2), as illustrated by the
following figure:
@b(1)=12 @b(2)=6
@a(1)=2 @a(2)=5 @a(3)=4 @a(4)=1
@a(1)=2 @a(2)=4 @a(3)=5 @a(4)=1
Using separate arrays for the columns/rows of A:
Note: if the source is a table in the sense of the table calculation module, the quantities are designated
by the column names.
■ calculation control
■ file i/o
■ system development support
■ various
The command explanations are collected into a separate section, organized as the main part.
The services that are not available as transparent commands must be made available separately in every task.
In most application tasks, the general services considered useful are installed. For the case that a function
for some reason is not available this way, there is the subtask SRV (services) containing a number of useful
functions. In addition to the functions presented here, it contains functions such as output of lists (SCAN),
output of plots (PLOT), the Text Editor (EDIT) and the general drawing task (DR).
Examples:
!COM GR.F list of functions provided by GR
!EXP GR.COLOUR: use of the function GR.COLOUR
!COM C.F: list of standard calculator functions
!EXP C.WLPOS: explanation for the function WLPOS
!COM B.F: list of NAPA BASIC commands
!EXP B.ONERR: explanation for the command @ONERR
!COM Q.HD: quantities used in HYD
!EXP Q.DISP: all explanations for DISP
!EXP Q.DISP/HD: explanation of DISP in HD
The explanations of quantities are only partially implemented.
This information is also available with the Help Viewer.
The number displayed at the end is a service for the system developers.
!VIEW
Without parameters, the !VIEW command lists information about current views:
nr name vis. proj. auto mode dest seg window upd
1 (BODYPLAN) X . 2D - 1 RS
==> 25 * 2D - 1 -
For more information, see chapter Graphics.
Other commands that produce information when given without parameters are
■ !PRINTER: current printer
■ !GR: current graphic output control (whether device or file)
■ !PAGE: current page size
■ !GRP: size of current drawing area
■ !ZOOM: zoom state
In addition, it provides various other service functions, of which those most likely to be needed are
Other aspects that can be controlled are storing of result, way of reacting to changed window size, and the
selection of the window.
Note: the CATALOG command can be used as an alternative to !SELECT. With CATALOG, the selection is
automatically restricted to the current type of objects.
The last alternative is consistently available in SH only. This so-called quantity criterion is entered after the
others separated by a minus sign.
Note: unless overridden by a VER criterion, the criterion VER=current is assigned automatically. One can
also add the option ALL, in order to include all versions.
The description type is expressed by an integer. However, it is most frequently needed for geometric objects,
for which the following symbols can be used
G geometry in general
P points
C curves
S surfaces
SO surface objects
R rooms
TAB tables
The database criterion uses information in the catalog of the database, and description contents do not need to
be fetched. It is therefore much faster to apply than the others. A strong database criterion makes the searches
more efficient when there are other criteria also.
Except when searching for geometric objects, it is necessary to know the database prefix for different types
of objects. For this, see below.
LOC=string equality
LOC>string begins with
LOC<string contains
The criterion <, 'contains', is typically useful for searching for strings in macros and it is applied case insensitively
(upper case and lower case equivalent), while the others are intended for isolated string items such as names
of compartments in a load case. The following examples search for macros containing PLOT and arrangements
containing R112 or R113:
!SELECT NAME>DATA* LOC<PLOT
!SELECT NAME>ARR* LOC=(R112,R113)
Note: for copying geometric objects, the command COPY in DEF is recommended. It provides the service
related to referenced objects.
DATA* macro
DRAW* drawing
FIG* figure (sysdb, NAPADB)
TAB* table (in general)
ARR* arrangement
PAR* purpose definitions
STR* collection of surface objects
LD*CON( loading condition
DAMCASE( damage case
CRIT( stability criterion
If the prefix ends with (, the name rule includes a ) at the end.
The service function AD.SUBJECT returns information on registered database prefixes.
In CATALOG, the prefix is automatically assigned according to the type of objects treated. In NAME criteria,
the tests are applied without the prefix and the output is shown without the prefix (unless option IP, include
prefix is given).
In !SELECT, the prefix must be included in the selection criterion if one wants to restrict it to a given type of
objects. However, it can be given as a separate item for giving the same effect as in CATALOG on the selection
criteria and the resulting arrays. Example:
!SELECT NAME>DATA*T
!SELECT DATA* NAME>T
These examples are equivalent as far as the set selected is concerned, but if the array LIST contains DATA*T1
and DATA*T2 in the first case, it will contain T1 and T2 in the latter case.
The service function AD.SUBJECT gives information about database prefixes in various ways, for example
Identify prefix:
!CAL AD.SUBJECT('TL','ARR*') -> arrangement
Get list of prefixes and explanations:
@PLIST=ARR(3) @TLIST=ARR(3) ceate receivers
@n=AD.SUBJECT('P',PLIST) get list of prefixes
@n=AD.SUBJECT('T',TLIST) list of explanations
ZMIN=0 equality
ZMIN>5 larger than
ZMIN<2 smaller than
ZMIN=2.5...4 range
NAME=HULL equality
NAME>HULL begins with
NAME<HULL contains
Examples:
SELECT NAME=HULL* begins with HULL
SELECT NAME='*HULL*' contains HULL
SELECT NAME=HULL? e.g. HULLA, HULLF
If a set of strings, for example, names like R11;R20,.., contains a number, the number can be used rather than
the string by adding prefix +, for example
+NAME>10
A subcriterion can be reversed by adding a minus sign:
Several subcriteria can be combined. Criteria written after each other imply AND between them, i.e. all criteria
must be satisfied:
NAME>HULL VER=A
In the example, both 'name begins with HULL' and 'version=A' must be satisfied. One can also combine
subcriteria with OR:
NAME>HULL OR TYPE=R
The whole criterion can be reversed by starting it with NOT:
NOT NAME>HULL OR TYPE=R
!VAR ON/OFF do/ do not react to the variable flag (@) in commands
!VAR OFF is the default in the Editor and when running DOC, otherwise !VAR ON.
!VAR DEC=dec number of decimals when replacing numerical expressions with their
values
!VAR NSD=n alternative to DEC, set number of significant digits
Because of the global effect of !VAR DEC, !VAR NSD, one should normally use the FMT function when a
specific accuracy is desired. The default is NSD=6.
The currently defined variables can be listed with
!VAR LIST
Elementary variables are presented as their values, while arrays and descriptions are given a short
presentation. The output can look like:
A= 12
B= 77
CATALOG= array, size=15 strings NAME (2875)
I= 12
MATREC= array, size=3 strings MAT (5305)
MT= description TAB*MATERIALS (3937)
NAME= 'DECK1'
RHOREC= array, size=3 reals RHO (5320)
V= 1205.3
Here, A, B, I, NAME and V are ordinary variables. CATALOG is the array created by the general catalog
function and MATREC, RHOREC are records fetched from the description MT. If the record number of an array
matches that of a standard quantity, the name of the quantity is added, but this interpretation is not necessarily
correct. The numbers in parentheses are the so-called reference numbers by which arrays and descriptions
are referred to internally.
The option * has the same function as in the !CALC command for accessing variables in an interrupted macro.
An array can be listed with !VAR LIST array. There are options with which the layout and format of the result
can be controlled. The following example gives the same array in two ways:
!VAR LIST ZREC
0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.03 0.06 0.10 0.16
0.22 0.30 0.38 0.48 0.58 0.69 0.81 0.93 1.07 1.20 1.35
1.49 1.64 1.80 2.77 3.74 4.71 5.68 6.65 7.62 8.59 9.56
10.53 11.50
!VAR LIST ZREC FORM=8.3 COL=7
0.000 0.000 0.000 0.000 0.000 0.000 0.007
0.026 0.058 0.101 0.156 0.222 0.297 0.383
0.477 0.580 0.691 0.809 0.934 1.066 1.203
1.346 1.493 1.645 1.800 2.770 3.740 4.710
5.680 6.650 7.620 8.590 9.560 10.530 11.500
Single variables can be deleted with !VAR DELETE and all variables with !VAR RESET.
Synonyms can be created between, for example, names or arrays and name of functions or names of variables
and names of table columns. This problem is addressed by the !VAR CHECK option. The output of !VAR CHECK
can be
Symbols without parameters
variable NAME overrides table symbol NAME
Symbols with parameters
function VOL overrides array VOL
The first problem is possible in the table calculation task: if there is a column NAME, the symbol NAME would
normally refer to it, but now there is a variable NAME that has precedence. The latter problem is the result of
creating an array named VOL. When entered with an index, it will formally look like the function VOL.
There is also the option
!VAR CHECK ON
This means that every time a symbol is interpreted, all possible interpretations should be tested and a warning
given if there are synonyms.
'unit' is 1...7 for NAPA databases and larger than 10 for ASCII files. 11, 12 and 13 should be used normally
(the same as allowed by !LINK).
The following options may be needed:
NEW: create a new file. Default=the command refers to an existing file
OVR: (overwrite) create a new file if it does not exist before
AUX: (with a project only): take the auxiliary database, default=the main project database.
The following examples show the use of the !OPEN command in typical connections.
Copy a version to a temporary file
This need may occur when a project is sent to another company.
TOC
!OPEN TEMP>P1234.DB 5 NEW
SELECT VER=A
UNIT 5
COPY TO 5
!CLOSE 5
Copy figures from another project
TOC
!OPEN P1234 5 AUX
SELECT NAME>DRAW* VER=A
UNIT 4
COPY FROM 5
!CLOSE 5
Write macro output to an ASCII file
!OPEN TEMP>TEST 11 OVR
!LINK 3 11
@@ 3=listclass 3, used by !OUTPUT, 11=file unit
@FOR I=1,10
!OUTPUT Line @i
@NEXT
!CLOSE 11
The resulting file will be
Line 1
Line
...
Line 10
Access an ASCII file in a macro
The following macro reads the file created in the preceding example.
!OPEN TEMP>TEST 11
@label next
@text=input(11)
@if text<'EOF' then
!TYPE @text
@goto next
@endif
@@ file closed automatically when end fo file reached
The PARSE function has been provided for accessing parts of a text string, and it may be useful when
interpreting file contents.
Example
!ENV DISPLAY
ns4:0
!ENV DISPLAY='ns3:0'
The value of an environmental variable can be accessed in a macro by the function MN.ENV(name).
5.11.2 Pause
Command !PAUSE makes the system wait for a specified time.
Note: full professional mode implies administrator rights only when no administrator has been declared in
the installation parameters.
GM.CHANGE: a room or surface object has been defined, two parameters, name and
type (R/SO)
TP.DEF: the DEF command of table calculation has been given, one parameter=key
value
LD.CHANGE: the loading condition has been changed
The INQ option in the !ACTION command gives a list of registered events, all of which are not implemented.