You are on page 1of 63

NAPA Online Manuals 2011.

2
General Tools and Functions

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.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

2 Graphical user interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3


2.1 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Widgets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Subsystems involved. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4 Functions of the group UI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4.1 Widget definition descriptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4.2 Widget manipulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4.3 Miscellaneous. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4.4 Internal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.5 Events of the group UI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.6 Functions of the group MTF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2
General Tools and Functions

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

5 Various general functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37


5.1 Help functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.2 Functions producing information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2
General Tools and Functions

5.3 Commands related to input and running macros. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41


5.3.1 !ADD, run macro. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.3.2 !DO, repeat commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.3.3 !L, list or run previous commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.4 Commands related to list output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.4.1 !PRINTER, default printer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.4.2 !PAGE, select page size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.4.3 !Header, control page headers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.4.4 !FORM, formatting of numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.4.5 !LINK, redirect list output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.5 Functions related to graphics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.5.1 !GR, various control functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.5.2 !E, screen erase. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.5.3 !GIN, control of graphic input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.5.4 !VIEW, management of views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.5.5 !WINDOW, create window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.5.6 !LAYER create/change layer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.5.7 !ZOOM, !PAN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.5.8 !SEND output of current graphics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.5.9 !GRPAGE, drawing area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.6 Doing catalogs and selections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.6.1 !SELECT command. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.6.1.1 Database criterion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.6.1.2 LOC criterion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.6.1.3 REF criterion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.6.1.4 USER criterion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.6.1.5 Quantity criterion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.6.1.6 Options telling how to return the result. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.6.2 General CATALOG function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.6.3 Copying data from other projects and versions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.6.4 !CATALOG command. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.6.5 Database prefix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.6.6 General selection syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.7 Functions related to the calculator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.7.1 Command !CALC, evaluate expression. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.7.2 Command !VAR, services related to the calculator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.7.3 Output function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.8 Control related to calculations and geometry. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.9 Functions related to file i/o and management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.9.1 Opening and closing files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.9.2 Reading and writing environmental variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.9.3 Other commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.10 Commands related to system development. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.11 Various functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.11.1 Output to the log. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.11.2 Pause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.11.3 Command !BELL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.11.4 Assigning full profession mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.11.5 Creating private lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.11.6 Assigning actions to events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.11.7 Assigning terminal properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.12 Transparent services for GM, SM and TAB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.13 Command specifications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.13.1 Help functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.13.2 Commands producing information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2
General Tools and Functions

5.13.3 Catalogs and selections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58


5.13.4 Functions related to the calculator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.13.5 Control of calculations and geometry. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.13.6 Functions related to file i/O. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.14 Commands for development and maintenance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.14.1 Various commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.14.2 Transparent services from GM, SM, TAB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 1 (58)
General Tools and Functions

1 General Service Functions and Events


This chapter presents service functions and events related to general system functions. For graphics, table
calculation and applications, see the respective documents.

1.1 Functions of group MN


These functions cover the same subject as the MN subsystem: project administration, run environment.

1.1.1 Information related to the current run

1.1.2 Project administration

1.1.3 Run-time error functions

1.1.4 Various

1.1.5 Program and user information

1.1.6 Printing. macros, lists

1.1.7 Licenses

1.2 Events of group MN

1.3 Functions of group AD


This group contains various functions related to quantity standard, LQ, PQ, date handling, reference system.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 2 (58)
General Tools and Functions

1.3.1 Functions related to quantities and units

1.3.2 Standard syntaxes

1.3.3 Functions treating LQ,PQ,TOO,POO

1.3.4 Check and information of data items

1.3.5 Arguments, report control

1.3.6 Various

1.3.7 String functions

1.3.8 Database

1.3.9 Functions related to the reference system

1.3.10 Functions related to process tables

1.4 Functions of group DB


This group contains functions concerning data in the database.

1.4.1 Function related to objects in the data base

1.4.2 Functions related to file management

1.4.3 Functions related to files in general

1.4.4 Functions related to data access and security

1.4.5 Various

1.5 Functions of group DM


This group contains functions concerning data in the run time memory.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 3 (58)
General Tools and Functions

1.5.1 Operations with descriptions

1.5.2 Operations with arrays

1.5.3 Various

1.6 Functions of group AI

1.7 Events of group AI

1.8 Functions of group AP

1.9 Events of group AP

1.10 Functions of the group OS


These functions give access to various operating system services, such as file operations.

1.10.1 Dynamic memory functions

1.10.2 File I/O functions

1.10.3 Other functions

2 Graphical user interface


This chapter contains a short introduction to implementation to the graphical user interface, including a
presentation of the related service functions.

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.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 4 (58)
General Tools and Functions

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.3 Subsystems involved


The functions specifically related to the user interface are handled by the UI subsystem. The underlying Motif
functions are available on the macro level as a separate set of service functions.

2.4 Functions of the group UI


This group contains functions supporting the graphical user interface.

2.4.1 Widget definition descriptions

2.4.2 Widget manipulation

2.4.3 Miscellaneous

2.4.4 Internal

2.5 Events of the group UI

2.6 Functions of the group MTF


This group contains basic functions provided by Motif. As a general rule, user macros should rely on functions
from the UI group rather than directly on MTF.

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.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 5 (58)
General Tools and Functions

3.1 What is the User Profile?


A User Profile is a text in NAPA that specifies the resource settings for widgets used in the NAPA GUI.
This text is created using the NAPA Text Editor and saved (usually in the System database) with the prefix
RES*. The specification of resources follows the standard Motif notation.
A widget is any identifiable part of the windows which form the GUI. For example, the buttons in a menu bar
are widgets, the menu bar itself is a widget, the entire window which uses the menu bar is a widget, the text
fields in the NAPA logon screen are widgets, etc.
Every widget in the GUI has characteristics or associated settings called resources. Resources control
such things as the appearance of the widget, the position of the widget, what happens when the widget is
"activated" (e.g. what happens when a button is pushed) or anything about the widget. The list of possible
resources for a widget is extensive and depends on the type of the widget. For example, a push button will have
different resources than a graphic drawing area, although some resources will be used by both types of widgets.
The specification of resources in a User Profile requires the name of the widget, the name of the resource and
a value for the resource.

3.1.1 Widgets and widget names


A window in a software application is a composite widget, i.e. it is composed of many smaller widgets, which
have been grouped together in some particular way to form the window you see on the screen. This is not
just the case for so called "main windows" like the NAPA main Task Window, the Geometry Window, or the
Loading Conditions window, but also for dialogs (e.g. the Document Formatter in the Test Editor Window).
The grouping of widgets can also be implemented in several stages, so that a more complicated widget formed
of many smaller widgets is used to make many different larger widgets or windows and dialogs. A prime example
of this is the table widgets used in NAPA. This widget, which is composed of many smaller widgets (e.g. text
fields and other components), is used as a part in other windows, like the Table Editor tool, the Ship Model
window, and the Subdivision Definitions window.
The basic principle, however, is that windows in a software application are composed of many smaller widgets.
The formation of these windows depends on the relations of the smaller widgets to the whole as well as to
each other, for example, is the widget a part of a larger widget, is it on the "same level" as another widget, as is
the case for a series of push buttons in a toolbar, etc. Composite widgets are formed based on a hierarchical
structure which specifies the relations of the component widgets to each other. When a widget is part of a
composite widget, we say the widget is a child of the widget. The composite widget (e.g. a window or dialog)
is referred to as the parent of the smaller widget. For example, the items in a menu are children of the menu
widget, which is itself a child of the menu bar, which is a child of some work area widget, which is a child of the
larger composite widget, i.e. the entire window. There are often invisible widgets as well which do not show up
on the screen, but they are used to specify the inter-relationships of the widgets in the window.
The reason for this rather technical sideline discussion has to do with widget names. Every single widget has
a name. The names of the widgets in NAPA cannot be controlled by the user. They are set whenever the widget
is created, for example, when you open the Steel Window, every button has a name. The name of a widget is
formed by a string, preceded by the names of ALL the other widgets which are parents of the widget.
For example, the actual complete name of the Draw button in the first Geometry window we open is:
napa.Main.GR_GeomWindow_#1.GR_PltWn.WA.Toolbar.GR_DrawTools.Draw
Note that the name components are separated by periods '.' This is called a hard binding and it refers to
one direct "step" in the widget hierarchy, for example, the widget after the period is on the next lower level.
This complete specification can be rather tedious to use, so wildcard characters (asterisks *) can be used to
substitute any parts of the name which are unnecessary or which we can generalized:
napa*ToolBar*Draw

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 6 (58)
General Tools and Functions

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.

3.1.2 Resources and resource settings


As mentioned above, every widget has resources, or characteristics which determine its appearance or
behavior. Examples of resources could be:
■ the background color
■ the text on a button
■ the text in a text field
■ the size of a graphic area
■ the font used for text
■ switches (True/False) to control whether or not something is visible.
In broader terms, the resources of a widget could also refer to data stored with a widget and the macros, i.e.
call backs, associated with events or actions involving the widget.
A User Profile is a text in NAPA which contains resource settings for the widgets in NAPA. User profiles do not
involve any call backs, but rather they control simpler things about the widgets, like color, size, appearance,
whether or not they are visible, etc. In the section Useful resources the types of resources which the user can
control via a User Profile are indicated. The possible values for a resource are also indicated in the section
below.

3.2 Resource files and User Profiles


The User Profile text is a normal text in the NAPA sense, stored in the SYSDB (DB2). The text is most easily
created in the Text Editor (Main Window, Tools menu, Text Editor). It is saved with the prefix RES*, which
stands for Resource Specification. An example of a User Profile is shown in the Text Editor below.

Example of a resource specification, i.e. a User Profile, in the Text Editor

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 7 (58)
General Tools and Functions

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.

3.3 Useful resources


It has become evident that the most difficult thing in making your own User Profile is determining the names of
widgets and useful resources to set. In this section some useful resource settings are discussed.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 8 (58)
General Tools and Functions

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.

Select Colour Dialog


The list given below is thought to be useful for those settings for which the default values may not be exactly as
the user desires. Other resource settings were considered to have little use for any setting other than the default.

Resource Purpose Possible Values Default


napa*background Background colour of See colours above Grey
all windows in NAPA
napa*foreground Foreground colour See colours above Black
napa*Main.title Title in title bar of the Any string NAPA
Main Window
napa*UI_Show_CommandArea.set Controls display of True,False False
the command area
napa*XmText.background Background colour See colours above White
for ALL text fields

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 9 (58)
General Tools and Functions

napa*MainW*CA.maxLength Command Log Size Up to 2 147 483 650 64000


(characters) of the (2**31-1)
text area of the Main
Window
napa*MainW*CA.rows Number of text rows Depends on monitor 24
in the command area size
in the Main Window
napa*MainW*CA.columns Number of columns Depends on monitor 72
in the command area size
in the Main Window
napa*MainW*DA.height Height of the drawing Depends on monitor 1
area in the Main size
Window (pixels)
napa*MainW*MB*DrawBox.set Activate drawing 0,1 0
toolbox in the Main
Window (requires
drawing area to be
opened)
napa*MainW*MB*ViewMP*ShowSB.set Show Status bar in 0,1 1
the Main window
napa*MainW*MB*ViewMP*ShowTb.set Show Toolbar in the 0,1 1
Main Window
napa*MainW*MB*ViewMP*Echo.set Turn on/off data 0,1 0
echo
napa*MainW*MB*OptionsMP*UndoSupport.set Turn on/off undo 0,1 0
support (functions in
text areas)
napa*GR_PltWn*GR_DrawTools*Plot.set Plot surface in the 0,1 0
GM window
napa*GR_PltWn*GR_DrawTools*PO.set Plot Point Objects in 0,1 0
the GM window
napa*GR_PltWn*GR_DrawTools*X.set X sections in the GM 0,1 0
window
napa*GR_PltWn*GR_DrawTools*Y.set Y sections in the GM 0,1 0
window
napa*GR_PltWn*GR_DrawTools*Z.set Z sections in the GM 0,1 0
window
napa*GR_PltWn*GR_DrawTools*Incl.set Constant inclination 0,1 0
curves plotted in the
GM window
napa*GR_PltWn*GR_DrawTools*Curv.set Curvature curves 0,1 0
plotted in the GM
window
napa*GR_PltWn*GR_DrawTools*Porc.set Poscupine plot 0,1 0
plotted in the GM
window

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 10 (58)
General Tools and Functions

napa*GR_PltWn*GR_DrawTools*Radi.set Radius of curvature 0,1 0


plotted in the GM
window
napa*GR_PltWn*GR_DrawTools*Sym.set Set Symmetry on in 0,1 0
the GM window
napa*GR_PltWn*GR_DrawTools*Net.set Draw Background 0,1 0
net in the GM
window
napa*GR_PltWn*GR_DrawTools*Clear.set Clear before drawing 0,1 0
in the GM window
napa*GR_Zoom3DDlg*SzCurrentObj.set Specification of 0,1
3D size and zoom
settings in all
drawing windows
napa*GR_Zoom3DDlg*NoChange.set Specification of 0,1
3D size and zoom
settings in all
drawing windows

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

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 11 (58)
General Tools and Functions

OF_MW Outfit MW_OF


WG_MW Weight Calculation MW_WG
MW_LD Loading Conditions MW_LD
DA_SUBD Subdivision Definition DA_SUBD

Note: the Widget Collection name is usable as the SOURCE TOOL in the Manager. See the chapter
Manager in the NAPA Monitor Manual.

3.3.1 NAPADB resource files


There are several resource specification files stored in the NAPADB which are intended to be used in user
profiles. These are:

Resource file (RES*) Purpose


FUNCTIONKEYS Define function keys' bindings (F1 - F12). See the
section below.
TINYLAYOUT Specifies layouts. This is a combination
of the corresponding RES*TINYFONTS,
RES*TINYFONTS2 and RES*TINYMARGINS
resource specifications
SMALLLAYOUT The same for SMALLFONTS, SMALLFONTS2 and
SMALLMARGINS
MEDIUMLAYOUT The same for MEDIUMFONTS, MEDIUMFONTS2
and MEDIUMMARGINS. This is the default NAPA
layout.
LARGELAYOUT The same for LARGEFONTS, LARGEFONTS2 and
LARGEMARGINS

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.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 12 (58)
General Tools and Functions

3.3.2 Key bindings


The key bindings of the function keys can be set up in NAPA using resource specification files. Default key
bindings are set in the resource specification RES*SYSTEM.
The function keys are F1, F2 ,... F12 offering 12 functions with a single key press. By combining these with
the Shift, Control and Alt keys, additional key combinations can be defined offering together more than 100
possible combinations. By default keys F1 and F10 have pre-defined functions. F1 opens the Help Viewer and
F10 activates the first item in the menubar of a window.
The special keys, called modifiers, are:
■ Shift <Shift>
■ Control <Ctrl>
■ Alt <Mod1>
■ Alt Gr <Mod3>
The format of key bindings is as in the following example; here the F7 key will print the key combinations to
the NAPA Main Window Command area:

Syntax for key bindings


This example is the resource specification file RES*FUNCTIONKEYS in the NAPADB.
Note the following:
■ Key combinations must be defined in the order where the simplest is the last.
■ The actual function is realised by Motif functions (please refer to Motif manuals for valid functions). Note
that the "insert-string" function above is used to add NAPA commands to the command prompt and the
"\n" insertion works as a hard return.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 13 (58)
General Tools and Functions

■ 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.

Resource specification file EXAMPLE

Resource specification file EXAMPLE2


We first login using the first example file EXAMPLE:

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 14 (58)
General Tools and Functions

The resulting Main Window of NAPA looks like this:

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 15 (58)
General Tools and Functions

Result of EXAMPLE resource specification


Then we use the RESET command at the TASK?> prompt and login again using the resource file EXAMPLE2.
The result is this time:

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 16 (58)
General Tools and Functions

EXAMPLE2 resource file specification

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.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 17 (58)
General Tools and Functions

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.

4.2 Run time information


Most of the information needed in daily work can be obtained online by the commands !COMMANDS and !
EXPLAIN. In order to distinguish the calculator oriented subjects from normal commands, the following syntaxes
have been selected:

!COM C.F list of standard calculator functions


!EXP C.id explanation of calculator function 'id'
!COM ss.F list of service functions from subsystem ss
!EXP ss.id explanation of service function 'id' of subs. ss
!COM B.F list of NAPA BASIC statements
!EXP B.id explanation of statement 'id'
!COM ss*E list of events provided by subsystem ss
!EXP ss*id explanation of event 'id' of subsystem ss

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

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 18 (58)
General Tools and Functions

!EXP B.ONERR: explanation for the command @ONERR


!EXP GM*CHANGE explanation of the event GM*CHANGE

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.

4.4 Basic concepts


The basic capability of the calculator is to evaluate an expression. Shortly defined, an expression has the
form of a normal arithmetic expression, in which some operands may be function calls. More precisely, an
expression is formed by the following components:
■ operators: + - * / = > < >=,<=,<> 
The first four ones are the normal arithmetic operators, while the last six ones are logical operators that
will be presented later. 
■ parentheses: ( ) 
The parentheses have their normal function of changing the precedence of operations. They also delimit
function parameters. 
■ functions (e.g. SQRT, SIN) 
A function is formed by a function name followed by a parameter list in parentheses. Functions are used
for all operations not expressed by the operators above. The parameter list is formed by one or several
expressions, separated by commas. 
■ constants 
The constants can be 
■ numeric constants, e.g. 12, 0.75
■ string constants, e.g. 'ABC'
A string constant is any set of characters enclosed in apostrophes.
■ variables 
A variable is represented by a name, and stands for a numeric value or a string value. 
■ arrays 
Arrays are collections of elements of the same type (numbers or strings). An array-element is designated
by the array name and an index within parentheses, e.g. X(3), HEIGHT(I) 
■ built-in constants, e.g. PI 

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 19 (58)
General Tools and Functions

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.

4.5 Variables and arrays


A variable represents a numeric or string value. When used in an expression, the variable is replaced by its
value before the expression is evaluated.
A variable obtains its value in an assignment, for example, @A=1 or by using the !CALC command. Variables
do not need to be created separately - this is done when the first assignment is encountered. Note, however,
that if a variable is used as an output parameter in a function call (e.g. BEND), it must exist at the call. The type
of the variable is numeric or character depending on the type of value last assigned.
An array differs from a variable in that it may stand for many values (of the same type). The individual values in
the array are designated by the index which is 1 for the first element. The index is written in parentheses after
the array name, and its value may be represented by any numeric expression.
An array can either be fetched with function REC or created by using the ARR function. The first parameter
of the ARR function tells whether the array shall contain integer values (1), decimal values (2) or character
values (3). An optional number (>1000) may be added, giving the array an internal name. This has the effect
that a possible repeated call of the ARR function with the same number returns the same array, instead of
creating a new one.
An array is identical with a record in the sense of the data management system of NAPA. Any record can
therefore be used as an array by storing the reference-number (as given by function REC) in a variable, and
using that variable as the name of the array. Many of the service functions return an array as the function value.
Examples:

X=ARR(2) an array named X is created for decimal values


NAME=ARR(3,1111) an array named NAME is created for character values and with the internal
identifier=1111
D=DB('HULLF')
NAME=REC(D,1510) array NAME is defined to be record 1510 (list of curves) of description
'HULLF'

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 20 (58)
General Tools and Functions

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

4.6 Logical expressions


In order to control decisions, the calculator also handles logical expressions. The basic functions are provided
by the comparison operators:

= equality (numbers and strings)


> greater than (numbers), begins with (strings)
< smaller than / not equal
>= greater than or equal / contains
<= smaller than or equal / ends with
<> not equal

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)

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 21 (58)
General Tools and Functions

(A+1)=B -> 1 (true)


A+1=B -> 3 (1=B ->0, A+0 -> 3)
NOT(A>B) -> 1
OR(B=0,A<B) -> 1
AND(B=0,A<B) -> 0
S='HULL' -> 0
SBS(S,1,4)='HULL' -> 1
10+(A>0)*A -> 13
10+(A>B)*A -> 10
'BA'>'A' -> 0 (BA does not begin with A)
'BA'<'A' -> 0 (BA is not equal to A)
OR(0,0,1) -> 1
AND(A>5,1) -> 0

4.7 Handling of functions


Functions are used for expressing all operations that are not covered by the operators. A function always
returns a value, but this need not necessarily be the essential result (as in functions BEND, SECT).
The result of a function is normally provided by the function-value, but it is also possible to use output
parameters.
The calculator is capable of handling functions with an arbitrary number of parameters, or functions that may
be called with different number of parameters in different contexts. It is further possible that a parameter can be
either a number or a string, with different interpretations (see parameter 'curve' of function AREA, for example).
The parameters themselves may be formed by any expression handled by the calculator.

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.

A list of all calculator functions is obtained by


!COM C.F
A presentation of a given function is obtained by
!EXPL C.id
for !EXPL C.AREA
The explanations obtained under !EXPL !CALC are not maintained since 97.1.

4.8 Subsystem service functions


The number of services provided via the calculator has grown steadily and in release 96.1 a new type of
functions has been introduced, called subsystem service functions. They differ from other functions in the
administrative sense only. The idea is that within each subsystem, as many functions as desired can be added
without burdening the set of reserved words and the functions can be implemented independently by the person
responsible for the subsystem in question.
The names of the subsystem service functions have the following form:
ss.funct(parameters)

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 22 (58)
General Tools and Functions

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:

AD various functions (lq, pq, quantities, arguments, dates, reference system,


selection ao)
AI functions related to input, macros
AP some functions related to text output
CP functions related to sounding devices
CR some functions related criteria
DA various functions related to damage stability
DB functions related to database and file access
DM general functions for handing data in the free storage
DR drawing functions, handling of setups
GM various functions related to geometry
GME the functions of the Hull Editor
GR functions related to graphics
GRE the marking functions
GS some functions related to grain stability
IN some functions related to volume calculations
INC functions related to the inclining test (mainly for ObN)
LD functions related to loading conditions (defining, getting information,
plotting, ObN related)
MGR the basic functions of the Manager
MN various functions of the Monitor (project adm., run control, printing,
licenses)
MTF the functions providing the interface to Motif
NPN the functions of the new panel definition task
OGL controlling OpenGL

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 23 (58)
General Tools and Functions

OS services of the operating system, various general data manipulation


RR roro/break bulk loading (ObN)
SB functions supporting the TRIBON interface
SHN functions supporting the power module of ObN
SM some functions related to the arrangement, outfit and routes
SP SECPRO functions
SQL temporary implementation of the SQL interface
ST NAPA Steel functions
STP functions implementing the STEP interface
TP interface to table calculation
TPL topology functions
UI basic functions of the graphical user interface
WPR Windows printer

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.

4.9 Summary of functions


This section contains a summary of the standard functions implemented. The next section gives a more detailed
presentation. For service functions, see the online explanations or the manual.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 24 (58)
General Tools and Functions

4.9.1 Mathematical functions

4.9.2 Logical functions

4.9.3 Date functions

4.9.4 String handling

4.9.5 Data management

4.9.6 Volume oriented functions

4.9.7 Functions for curves and surfaces

4.9.8 Functions related to the arrangement

4.9.9 Various functions

4.9.10 Support functions for the calculator

4.9.11 Functions operating on arrays

4.9.12 Functions available under table calculation

4.9.13 For container loading

4.10 Parameterless functions and constants


The following symbols are available as constants or parameterless functions:
Some of the above mentioned functions are valid in the proper context only: CLINE when a result list is open,
SCL when a drawing is open, CLN, NLN in task TAB, UINPUT, VINPUT, PINPUT when graphic input has been
done. EDTEXT and EDLINE require that there is a text in the editor work area. EDLINE could be used after
doing a LOCATE or similar operation. When the current line is at the start of a text, the reference number points
at a flag record preceding the text.

4.11 Multiply defined symbols


A common source of confusion is the fact that a calculator symbol can stand for different things and therefore
become multiply defined.
A name without a parenthesis directly following can have one of the following meanings:
■ a table element
■ a variable
■ a parameterless function (e.g. RO, SCL)

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 25 (58)
General Tools and Functions

■ the name of a quantity


A name with a parenthesis directly following can have one of the following meanings:
■ a calculator function with parameters
■ an array element
■ the value of a quantity with an index (under SH)
■ a table value from another line than the current line
These interpretations are attempted in the order presented.
The interpretation as a table value requires that there is an active table (current task is table calculation). The
interpretation as a quantity is possible under SH and in some functions of the main NAPA, for example, when
listing an LQ-controlled table.
As a check against ambiguities, command !VAR CHECK is provided. For example, after doing
!CALC LREF=105
!CALC VOL=ARR(2)
!VAR CHECK gives
Symbols without parameters
variable LREF overrides function/const. LREF
Symbols with parameters
function VOL overrides array VOL
With option
!VAR CHECK ON
the check mode is set, where all possible interpretations are done whenever a symbol is interpreted, and
if ambiguities are found, a warning is given. Otherwise, the interpretation is finished as soon as a valid
interpretation is found.
In order to reduce the possibilities for ambiguities, variables no longer used can be deleted with command !
VAR DELETE (one variable), !VAR RESET (all variables) or !VAR RESET T (all variables added in the task just
finished). The last possibility is provided especially for those variables that some tasks automatically create.

4.12 Detailed presentation of functions


This presentation may not be up-to-date in all respects. The most up-to-date information is found in the online
explanations provided by !COM C.F and !EXP C.id.

4.12.1 Mathematical functions


■ SQRT(x), EXP(x), LN(x), LOG(x) 
Square root, exponent, natural logarithm and Brigg's logarithm of x. The function EXP(x,a) means x
raised into power a.
■ SIN(phi),COS(phi),TAN(phi),ATAN(tan) 
The normal trigonometric functions, where phi must be in radians and the arcus tangent is returned in
radians. ATAN(y,x) means ATAN(y/x), with the quadrant selected according to the sign of x and y and
with x=0 possible. 
The built-in constant RO=PI/180 can be used for converting degrees to radians or vice versa, e.g
SIN(90*RO) gives 1.
■ MIN(x1,x2,...), MAX(x1,x2,...) 
These functions return the smallest or largest value of the parameters, the number of which may be any
value >1. (One value will be interpreted as a reference to an array, see below).
■ INT(x), ROUND(x,d) Truncation and rounding. For example, INT(12.8)=12, ROUND(12.8)=13,
ROUND(12.82,0.1)=12.8.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 26 (58)
General Tools and Functions

■ MOD(x,d): Division remainder, for example, MOD(127,10)=7, MOD(82.32,1)=0.32. 


■ ABS(x): Absolute value, for example, ABS(12.5)=12.5, ABS(-12.5)=12.5.

4.12.2 Logical functions


■ NOT(x) 
Returns 1 (true) if x is false (zero or negative), 0 if x is true.
■ OR(x1,x2,...) 
Returns 1 if at least one of the xs is true (=positive) otherwise 0.
■ AND(x1,x2,...) 
Returns 0 if at least one of the xs is false (=zero or negative), otherwise 1. 
■ EQUAL(x1,x2,tol) 
Performs equality test with explicit tolerance, for example, EQUAL(12.121,12.123,0.001)=0 (false),
EQUAL(12.121,12.123,0.01)=1. The operator = uses a fixed tolerance 0.000001.

4.12.3 Date functions


■ DATE(idate): returns the date as integer YYMMDD when given the internal date. 
The parameterless function IDATE returns the current date (and time) in the internal form, the unit of
which is seconds. The built in constant SPD (seconds per day) can be used for converting seconds to
days or vice versa. 
(The NAPA internal date is expressed as seconds from 00.00/1.1 1964)
■ TIME(idate): returns time as integer HHMMSS when given the internal date
■ IDATE(date) or IDATE(date,time): returns internal date, when given date (and optionally time) in the form
above. For example 
IDATE>IDATE(900916,214500) 
is true if the current date is later than 21.45 on 16. sept, 1990.
■ FDATE(idate): (formatted date) returns date in output form YY-MM-DD or the form defined in the
installation parameters
■ FDATE(idate,form): date in the specified form: 1=from operating system, 2=yyy-mm-dd, 3=yy-mm-dd,
4=dd.mm yyyy, 5=mm/dd/yy
■ FTIME(idate,form): (formatted time) returns time in the form HH.MM. Form parameter analogically with
FDATE.
For more date functions, see service functions of AD.

4.12.4 String handling


■ FMT(value,d,f): convert number to string. f=field length, default=min nr. of characters required. d=number
of decimals, default=as needed to represent the value. With the additional parameters unit and quantity,
unit conversions and labels can be added, as presented below. 
■ VALUE(string): convert string to number. The value of 'string' must contain a valid number as part. For
example, VALUE('FR2')=2.
■ SBS(string,i1,i2): returns the substring formed by characters i1 to i2 of 'string', for example,
SBS('WL10',3,4)='10'. If i1=1, it may be omitted. A negative index means counted from the end of the
string. 
When applying SBS, the given string is treated as if extended with spaces. For example, SBS(S,12)
returns a string of length 12 regardless of the number of characters in S, which may be useful in
formatting output.
■ CNC(string1,string2,... ): concatenate strings, for example, CNC('A','B','C') is 'ABC'
■ LEN(string): length of string, for example, LEN('ABC') is 3
■ LEN(string,ss): position of substring, for example, LEN('STABHULL','HULL') is 5. If the substring is
missing, 0 is returned.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 27 (58)
General Tools and Functions

■ 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.

4.12.5 Various functions


■ RESULTOF(macro,parameters): value calculated by the given macro. The remaining parameters are
passed to the macro. The macro is run in the so-called immediate mode and it can contain NAPA BASIC
commands only.
■ VALUEOF(expression): this function gives another round of evaluation. For example, if S='2+2',
VALUEOF(S)=4.
■ ASSIGN(var,expression): this function is the reverse of the preceding one and makes it possible to assign
a variable when the name of the variable itself is given by a variable or expression.
■ GLOBAL(name): get value of global variable regardless of visibility.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 28 (58)
General Tools and Functions

■ 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)

4.12.6 Data management


■ DB(name,unit,version): description from the database. 
The function value is the so-called reference number, by which the description is referred to other
calculator functions. 'version' is optional, default is the current version except for unit 2, where it is
empty. 'unit' means database unit. It can be omitted if the version is also omitted. Default for the unit is 1
(normally project database). (Command !OPEN can be used for getting access to any existing file). 
Special cases are DB(d,'WRITE') for writing the description given by reference number d to the (project)
database, DB(-d) for deleting from the run time memory, DB(name,0) for creating a description in the run
time memory, and DB(d) for returning the name of a description. 
Note: all this functionality is also available in the group of service functions belonging to DB. 
■ REC(descr,recid,n): get record in description. 
The function value is the reference number analogously with the preceding function. When assigned to a
variable, the variable defines an array. 'descr' is the reference number of the description, 'recid' specifies
the record by either record number, quantity symbol or name of table column. The optional n specifies
which record to take if there are several with the same number. 
The parameter 'descr' may also be given by the reference number of a record, in which case the result is
fetched among the records following the given one. In the form REC(rec,0), the next record after 'rec' is
returned. 
With n=-1,-2, or -3, a record of type 1,2 or 3 is added. See also functions DM.GETREC, DM.NEWREC. 
■ RSIZE(rec, size): returns or defines the number of elements in the given record or array. The function
value is the size at the call. With the optional parameter 'size', the size is adjusted to the given size. For
example, RSIZE(A,0) empties the array A.
■ RVAL(rec,index): returns the value of the given record at the given index. The same effect is achieved by
an array reference of the form 'rec(index)', but this cannot be used if 'rec' is specified by an expression.
■ LOCS(rec,value): returns the index of a string or number in the given record. Zero is returned if the string
or number is missing. When used with a number, the result may contain a fraction. For example, if the
array contains the numbers 10,20 and 30, and value=25, the result is 2.5
■ ARR(type, id): create array. Type 1=integers, type 2=reals, type 3=strings. For the optional 'id', see
paragraph about arrays. A special use of the ARR function is to inform that a variable refers to a an array.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 29 (58)
General Tools and Functions

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.

4.12.7 Functions related to objects with a volume


■ VOL(name,t,tr,heel): volume. Like the other volume oriented quantities, a shell thickness is included if
defined.
■ MOM(name,axis,t,tr,heel): moment
■ CG(name,axis,t,tr,heel): center of gravity of volume
■ LL(name,axis): lower limit
■ UL(name,axis): upper limit
■ AA(name): approximate area, bottom area approximated as the volume divided by the height (vol/(zmax-
zmin).
■ BA(name,a): bottom area, calculated as described is S.2. The optional parameter a is an array, into which
the area, the center of gravity and the length of the section are stored.
■ INQNT(name,qnt,t,tr,heel): quantity selected from the set presented below.
■ INQNT(obj,x,t,trim,heel,arr): alternative form: the function value is the area of the section at x, delimited
as implied by the given water plane. The parameter 'arr' is optional, and gives the name of an array into
which the area, y- and z-coord. of center of gravity are stored (in this order).
■ AREA(name): 'wall area' (when applied to a room), i.e. the area of the limiting surface. This area is
calculated from the calculation sections according to a heuristic method that may be inaccurate in some
cases.
■ WLPOS(name,volume,tri m,heel): 'waterline position', see below.
The following parameters are optional, and may be omitted beginning from the end:
■ axis, 1=x, 2=y or 3=z, default 1
■ t: draught, default whole object
■ tr: trim in meters (the normal NAPA input form), default 0
■ heel: heel in degrees, default 0.
Note that the parameters trim and heel are entered in the normal input form, which has been considered
practical in most cases. However, when fetching the values from the database, heelings and trims are in
radians. The conversion of trim in radians (tr) to trim in meters (tm) and vice versa is done by
tm=lref*tan(tr)*trsign
tr=atan(tm/lref)*trsign

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 30 (58)
General Tools and Functions

where trsign is +1 or -1 and tells whether trim by head is positive or negative.


Examples:
@vtot=vol('stabhull')
@v1=vol('stabhull',5,1) (t=5, trim=1 (m), heel=0)
@zcg=cg('R123',3)
@lz=ul('r123',3)-ll(r123',3)
@t=wlpos('hull',1000) (draught when given volume)
The functions VOL and CG can return the results for a partial object, by giving an array containing limiting
coordinates as the second parameter. Example:
@limits=arr(2)
** @parse('-999 50 -999 999 -999 999',LIMITS)
@volaft=vol('STABHULL',LIMITS)
The limits are given by an array containing xmin, xmax, ymin, ymax, zmin and zmax. All limits must be given,
although the upper x limit only is relevant in the example. This function is not implemented for objects containing
other transformations than reflection around y=0.
The function INQNT returns the basic volume oriented quantities (volume,moments), quantities related to the
waterline area (area, moments) and various derived quantities. The quantity is designated by the symbol stored
in the quantity standard. Available quantities are:
Available quantities in INQNT
Quantity Explanation
AREA wall area
DISP total displacement
IX longit. moment of inertia of waterline area (synonym
of WIX) about CGX
IXXV moment of inertia of volume Ixx about center of
volume
IXY moment of inertia Ixy of waterline area
IXYV moment of inertia of volume Ixy about center of
volume
IXZV moment of inertia of volume Ixz about center of
volume
IY transv. moment of inertia of waterline area (synonym
of WIY) about CGY
IYYV moment of inertia of volume Iyy about center of
volume
IYZV moment of inertia of volume Iyz about center of
volume
IZZV moment of inertia of volume Izz about center of
volume
KML longit. metacenter height
KMT transv. metacenter height
LCB longit. center of buoyancy
LMA longit. moment of waterline area (synonym of LMWA)

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 31 (58)
General Tools and Functions

LMD longit. moment of displacement


LMV longit. moment of total volume
LMWA longit moment of total waterline area
LOS length below waterline
MCT moment to change trim
TCB transv. center of buoyancy
TCP immersion/cm
TK draught below keel
TMA transv. moment of waterline area (synonym of
TMWA)
TMD transv. moment of displacement
TMV transv. moment of total volume
TMWA transv. moment of total waterline area
TMY transv. moment of inertia of waterline area at 50%
filling
VCB vertical center of buoyancy
VMD vert. moment of displacement
VMV vert. moment of total volume
VOLM volume moulded
VOLT total volume
WCGX longit. center of waterline area
WCGY transv. center of waterline area
WIX longit. moment of inertia of waterline area about CGX
WIY transv. moment of inertia of waterline area about
CGY
WLA waterline area (synonym of WLAT)
WLAM waterline area moulded
WLAT waterline area total
WSA projected wetted surface area
IYMAX maximum transv. moment of inertia of waterline area
TIYMAX T at which IYMAX occurs

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)

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 32 (58)
General Tools and Functions

@t=wlpos('hull',1000,53,0,5,flpos)
The array FLPOS contains draught, trim and heel as the three first elements.

4.12.8 Functions for surfaces and surface objects


■ AREA(name,laxis,l1,l2): area of surface
■ CGA(name,axis,laxis,l1, l2): center of gravity of surface
@A=area('BH1')
@A2=AREA('BH1',3,-1,3.5)
@Z=CGA('BH1',3)
■ DIST(name1,name2,p1,p2): the smallest distance between the given objects. The optional output
parameters (arrays) are the points corresponding to the smallest distance. One or both of the objects can
be a curve, point object or a point represented by the syntax '(x,y,z)'. If one of the coordinates x,y or z is
replaced by the character '-', the object is a line that is parallel to the corresponding coordinate.
@D=DIST('HULL','POINT1')
@D=DIST('POINT1','POINT2')
@D=DIST('HULL','(33.4,4.6,12)')
@P1=ARR(2)
@D=DIST('HULL',(33.4,5,0)',P1)
-> P1=nearest point in HULL
@D=DIST('HULL',(33.4,5,-)',P1)
...-> P1=intersection with x=33.4,Y=5
The parameters laxis, l1 and l2 are optional, and restrict the area to be calculated to the part between limit l1
and l2, measured on 'laxis' (1=x, 2=y and 3=z).
Functions UL and LL can also be used for surfaces.

4.12.9 Functions related to arrangements


■ FCODE(id): filling code (device code or logical fill code) corresponding to the given contents symbol. The
current filling standard is applied (can be checked with !SM FST). If none is active, the default standard
for compartment purposes is used.
FILL @FCODE('BW')
■ CPP(name,par): gives any parameter handled by SM, 'par' gives the parameter by the standard symbol,
e.g. PERM, VOLM.
@CPP('R123','PURP')
■ PP(id,par): gives the value of a parameters associated with the purpose identifier 'id'. 'par' gives the
parameter as above. Possible values are PDES, TYPE, CLASS, RHO, STRD, CAP or others added to
the current PAR* table.
@PP('BW','RHO')
Since data related to arrangements is treated as tables, the service functions of the group TP are available.

4.12.10 Intersecting an object


The function SECT(name,axis,q,cname) intersects an object with a coordinate plane defined by axis (1=x,
2=y, 3=z) and the coordinate q. The function value is the reference number of the resulting curve. 'cname' is
optional, and gives the name of the curve, default 'SECTION*'. The curve is not stored, but the name can be
used in command PLOT, for example. The function value is useful as the parameter 'curve' in the functions
presented below. Example:

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 33 (58)
General Tools and Functions

@c=sect('HULL',1,75)
@a=area(c)

4.12.11 Functions operating on curves


The parameter 'curve' stands for the curve name or the reference number returned by SECT or DB functions.
The parameters designated by c or c1,c2 can be reference numbers only.
■ AREA(curve,laxis,l1, l2): area enclosed by the curve
■ CGA(curve,axis,laxis ,l1,l2): center of gravity of the area
In the functions above, the optional parameters laxis, l1 and l2 limit the curve as presented for surfaces. For
open curves, laxis also provides the 'argument' axis, which together with the curve defines the area. Default=z
for x- and z-sections, x for z-sections.
■ POINT(curve,axis,q,n,q axis): identifies a point on a curve where a given coordinate ('axis'=1,2 or 3) has
a given value ('q'). If several points correspond to the criterion, the optional parameter 'n' can be used for
selecting between these. 
If the last parameter 'qaxis' is given, the function value will be the coordinate value on this axis.
Otherwise, the function value is the so-called point parameter, by which the point is designated in other
functions (CCORD, LENGTH,INCL).
@P=POINT('STEM',3,3)
@A=INCL('STEM',P)/RO
@X=POINT('STEM',3,3,1,1)
■ COORD(curve,axis,point): returns the coordinate of a point on a curve, when given the axis (1,2 or 3)
and the point parameter (as returned by POINT, PLENGTH, IBC or DVSG). The point parameter for the
startpoint is 1. Negative values mean values counted from the endpoint; therefore, -1=endpoint. 
The function can also be applied on a point object, but then the parameter 'point' is omitted.
@X=COORD('STEM',1,1) (startpoint)
@z=COORD('POINT1',3)
■ LENGTH(curve,point): returns the curve length from the startpoint to the point given by the point
parameter, or if the parameter is omitted, the whole length.
@L=LENGTH('STEM')
@C=SECT('HULL',1,X)
@L=LENGTH(C)
@P=POINT(C,3,ZDWL)
@LZ=L-LENGTH(C,P) (startpoint upper end)
■ PLENGTH(curve,l,qaxis): returns the point on the given curve that has the given distance from the
startpoint, measured along the curve. The result is returned in the same way as in POINT.
@P=PLENGTH('STEM',5)
@Z=COORD('STEM',P,3)
height of point at 5 m from startpoint
■ INCL(curve,point ,vect): returns the inclination of a curve. Without the parameter 'vect', the curve must be
a principal plane curve, and the result is returned as the inclination (in radians) in the plane of the curve.
The parameter 'vect' is optional and it must be the name of an array, into which the curve direction is
stored as a vector.
@T=INCL('STEM',POINT('STEM',3,5))/RO
-> inclination of stem at z=5
@P=POINT('KNF',1,46)
@V=ARR(2)
** @INCL('KNF',P,V)

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 34 (58)
General Tools and Functions

-> V=direction vector of KNF at x=46


■ BEND(u1,v1,a1,u2,v2,a2,r,us,vs,ue,ve): endpoints of circular bend. This function calculates the endpoints
of a circular bend, when given the radius (r) and the tangents (u1,v1,a1), (u2,v2,a2) (point+angle).
The result is delivered in output parameters (us,vs)=startpoint, (ue,ve)=endpoint. The function value is
irrelevant (assigned 1). 
■ DVSG(c1,p1,c2): 'developable surface generator'. This function helps defining a developable surface
between two curves. c1 and c2 stand for the reference numbers (note) of two curves. p1 is a point on
the first curve, as returned by functions POINT (short form) or PLENGTH. The function value is the point
p2 on c2, such that the straight from p1 tp p2 can be used as generator for the surface (the curves and
the straight have a common tangent plane). The following examples show how to get a point P2 on the
other curve after selecting a point P1 on the first one. For more information, see macro DVSGEN in the
NAPADB.
@C1=DB('CURVE1')
@C2=DB('CURVE2')
@P1=POINT(C1,1,X)
@P2=DVSG(C1,P1,C2)
■ CPART(c,axis,l1,l2,name): creates (in the run time memory) a curve named PART, formed by the given
curve, restricted to the part between the given limits l1 and l2, measured along 'axis'. The function value
is the reference number of the part. 'name' is optional and it gives the name of the result, default=PART.
@C=CPART('STEM',3,-1,5,'STEML')
-> part of stem below z=5, named STEML
■ CPART(c,nr,name): as above, but the part is selected as the given curve branch. nr=0 is a special
case: the branches of the curve are connected in order to give a single branch. The need for the latter
function typically occurs with a section near the bulb, and the result is needed in a context where multiple
branches do not work.
@C=SECT('HULL',1,82.5)
@B1=CPART(C,1) first branch
@B2=CPART(C,2) second branch
@B0=CPART(C,0) both branches connected to one
■ IBC(c1,c2): intersection between curves. The function value is the point parameter (as in function
POINT) of the point on curve c1 where the curve is intersected by C2. Note: c1 and c2 must be reference
numbers (from the SECT or DB function).
@C1=DB('FR8')
@C2=DB('WL6F')
@P1=IBC(C1,C2) (P1=point on FR8)
@P2=IBC(C2,C1) (P2=point on WL6F)
@Y=COORD(C1,P1,2)

4.12.12 Functions operating on arrays


In the following functions, parameters x and y stand for arrays, as obtained from the ARR or REC functions.
■ SORT(array,order): sort array. For the optional parameter order, see below.
■ SUM(x): sum of values in the array.
■ AVR(x): average of values in the array
■ MIN(x): the minimum value in the array
■ MAX(x): the maximum value in the array 
■ PSUM(x,y): sum of products between two arrays: x(1)*y(1)+x(2)*y(2)...
■ SOLVE(op,A,B,x): solve system of linear equations, presented more closely below.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 35 (58)
General Tools and Functions

■ 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.

Effect of smoothing (thin line)


The function SORT sorts an array or tells the order in it. When the array is given alone, the result is returned
by modifying the array, e.g.
!CAL SORT(A)
With an integer array (note) as the second parameter, the main array is not changed, but the order is stored
in the integer array. Example
@A=ARR(3) @A(1)='B'
@A(2)='C' @A(3)='A'
@IO=ARR(1)
** @SORT(A,IO)
!VAR LIST A
B C A
!VAR LIST IO
3 1 2
The function value is not used (assigned 0).
The calculator function SOLVE solves a system of linear equations as expressed by
A x = b
where x and b are vectors of size n and A a matrix of size n*n. The function call is

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.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 36 (58)
General Tools and Functions

The parameter op tells whether the matrix is given by rows (op=1) or by columns (op=2), as illustrated by the
following figure:

Effect of parameter op in the SOLVE function


The following examples show how to solve the equation system of the example using all the four possible ways
of representing the matrix A:
Using a single array for A:
@a=arr(2) @b=arr(2) @x=arr(2)

@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:

@aa=arr(1) @b=arr(2) @x=arr(2)


@b(1)=12 @b(2)=6
@a1=arr(2) @aa(1)=a1
@a2=arr(2) @aa(2)=a2
@a1(1)=2 @a1(2)=5 @a2(1)=4 @a2(2)=1
@a1(1)=2 @a1(2)=4 @a2(1)=5 @a2(2)=1
It is necessary that the arrays are of the correct type (real arrays except for the array aa). The array sizes must
be consistent: if n is the number of variables, arrays aa,a1,a2,... and b must have size n and array a size n*n
in the example above. The size of the output array x is adjusted to be n. Use the function RSIZE to truncate
the arrays if needed (e.g. @RSIZE(A,N*N)).
The function value is zero if the operation has been carried out successfully. Otherwise, the following codes
are returned:
1: no result because the matrix is
singular
2: no result because the arrays have incorrect type or size

4.13 Handling of upper case and lower case


Names of variables, functions and quantities are internally stored in upper case, and any names encountered
in an expression are converted to upper case.
The same concerns such string constants that are known to represent data handled in upper case (e.g. names
of objects).
When needed, case conversions can be done with function LCASE.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 37 (58)
General Tools and Functions

4.14 Current source description


In the SH subsystem and in some functions elsewhere in NAPA, there is a current source of data, from which
data can be designated by the names of quantities. Such a source description can be assigned with !VAR
ASD name.
When there is such a source active, containing some quantities, the symbols of the quantities designate their
values, as stored in the source. The symbol can be used as an array, if there are many values stored. The
symbols can also be used in assignments.
Supposing that the source description contains quantities RHO, VOLM and CGX, the following are valid
operations:

!CAL RHO display value of RHO


!CAL VOL(5)*RHO multiply the 5. element of VOL with RHO
!CAL CGX(3)=12 assign a value to the 3. element of CGX.

Note: if the source is a table in the sense of the table calculation module, the quantities are designated
by the column names.

5 Various general functions


This chapter presents functions that provide services of general nature and that are available everywhere or
in all relevant contexts.
Most of the functions described here are available as so-called transparent commands. It is characteristic for
these commands that
■ they are available everywhere
■ they are carried out without the current application program knowing it (which is why they are called
transparent).
The latter property means that the application programs cannot check or take into account the effect of
commands that influence the function of the program, and therefore, the use of some commands is allowed
only if the full professional mode is on.
Transparent commands are identified by an asterisk (*) or an exclamation mark (!) as the first character (e.g.
*REF or !REF). These two characters are interchangeable, except in the Editor and the documentation system,
where only the exclamation mark is recognized.
This chapter gives an overview of the functions and their purpose without attempting to present all the details
of their use, which can be obtained from the command explanations. A short summary is given over functions
presented in more detail in separate documents.
The functions have been grouped as follows:
■ help functions
■ information of various kind
■ input, running macros (summary)
■ listing (summary)
■ graphics (summary)
■ catalogs and selections
■ the calculator (summary)

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 38 (58)
General Tools and Functions

■ 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).

5.1 Help functions


A list of commands available in the current subtask is obtained by command
!COMMANDS
In order to find a command for a specific purpose, it may be useful to look for a command, the explanation
of which contains a given keyword:
!COMMANDS keyword
For example, !COM PAIR gives in LD the following output
PAIR define tank pairs
LOAD load/unload compartments +
DESCRIPTION list definitions in input form
POLYGON Definition of polygon-formed free surface moment
The list of transparent commands is obtained by
!COMMANDS !
The complete explanation of a command is obtained by
!EXPLAIN command
where 'command' is the name of a command. Some command explanations are so long that they have been
divided into parts that can be listed separately. A + in the output from !COMMANDS signals the presence of
parts and !EXPL COMMAND + gives a list of the parts and the name by which it is designated in !EXPL.
As short presentation of the command format(s) is obtained by
!PARAMETERS command
The !EXPLAIN command also gives the explanation of an error number:
!EXPLAIN nr
This gives the full explanation, while the text associated with an error message only contains the first line.
The command !DOC was introduced in order to help find information in the documentation. After the
documentation method has been changed, this command is no longer available, except for finding information
in documents produced before Release 96.1.
With the special conventions listed below, !COMMANDS and !EXPLAIN also give information on the following
subjects:

!COMMANDS C.F list of standard calculator functions


!EXPLAIN C.id explanation of calculator function 'id'
!COMMANDS ss.F list of service functions from subsystem ss

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 39 (58)
General Tools and Functions

!EXPLAIN ss.id explanation of service function 'id' of subs. ss


!COMMANDS B.F list of NAPA BASIC statements
!EXPLAIN B.id explanation of statement 'id'
!COMMANDS ss*E list of events provided by subsystem ss
!EXPLAIN ss*id explanation of event 'id' of subsystem ss
!COM ss.Q: list of quantities of subsystem ss
!EXP Q.id: explanation of quantity 'id'
!EXP Q.id/ss: quantity id of subsystem ss

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.

5.2 Functions producing information


This section presents commands producing information of general nature, without influencing the run. Some
of these have some other function as their main purpose, which is described in the respective contexts.
!WHERE
gives information about the current run, as illustrated by the following example:
In run R4298*JVH treating the ship D-STAR-K/A
Active task is T-CALC 96-03-19 19.06 (T)
JvH Test program
When needed, information on special circumstances is added, for example, if the version is read-only.
This command should be distinguished from the local WHERE commands (without exclamation point), available
in many tasks and giving task-specific information.
!DATE
tells the current date, time, day of week and time of sunrise, sunset:
TODAY IS WEDNESDAY 96-03-20
WEEK 12
TIME IS 10.42
TIME OF SUNRISE IS 6.29
TIME OF SUNSET IS 18.27
!REF
lists the most important reference dimensions:
LREF= 82.00 BDWL= 13.00 TDWL= 4.80

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 40 (58)
General Tools and Functions

XREF= 41.00 XMID= 41.00 APP= 0.00


!NEWS, !ERR
list information about new features and known bugs. The commands are context sensitive and give information
related to the current task.
!FRN
converts x-coordinates to frame numbers and vice versa
!FRN 6 -> FRO=10
!FRN #10 -> X=6
!DTX
lists the values of the so-called dynamic texts. This is a facility introduced before there was the calculator,
for providing flexibility in various contexts (TEXT command of the drawing task, !HEADER ao). The texts are
represented by a symbol that is replaced at output by a value (e.g. PRO -> current project). They can be
accessed in macros by the calculator function DTX. The following is a sample of output from !DTX:
USER=JVH SGN =SIGN JVH PRO =D-STAR-K
VER =A PRV =D-STAR-K/A CPV =A
DATE=96-03-20 DT =DATE 96-03-20 TIME=10.50
TM =TIME 10.50 PRD =96-03-19 RUN=R4298*JVH
PROG=T-CALC SPR =NAPA/T-CALC SYSL=D
CSID=NAPA/D/T-CALC/96031YARD=Helsinki CONC=Napa Oy
YCN =Napa Oy Helsinki LREF= 82.00 BDWL= 13.00
ZDWL= 4.80 XREF= 41.00 YDNR=
SNAM=Napastar
!CATALOG
produces a catalog from the database. For details, see below.
!VERSION LIST
This command gives a list of versions in the current project:
Version created by stat description
A 950901 JVH initial version
B 951210 JVH length=120 m
The main function of the !VERSION command is to change version. This should normally be done by the
VERSION command on the TASK level, using !VER for this purpose requires full professional mode.
!OPEN LIST
The main function of this command is to open files for various special purposes, as presented below. With
parameter LIST, it gives a list of open database units, including the intermediate output file (IOF):
Currently open database units
1 /n/hw/nps12/d-star-k.db
2 /n/hw/nps12/sysdb
4 /n/hw/nps12/d-star-k.sd
7 /n/hw/nps12/napadb
8 /n/hw/nps12/iof
!FORM quantity
gives the formatting parameters and explanation (the so-called long header) of a quantity, for example
!form vnet
*FORM VNET 8.1 M3 LH='net volume' SUM=D; ** 2209

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 41 (58)
General Tools and Functions

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

5.3 Commands related to input and running macros


The functions related to input are presented more closely in a separate chapter, and here is only a short
summary.

5.3.1 !ADD, run macro


The !ADD command runs a macro:
!ADD macro
The main variations are use of other sources than the default, running in step mode (option S).
There is also the command !RUN, which runs the macro in immediate mode. This is mainly useful for testing
the macro; otherwise, there is no difference to using !ADD.

5.3.2 !DO, repeat commands


The !DO command runs a macro or given commands repeatedly. The main variations are

!DO commands repeat for the given range


var=(l1,l2,d)
!DO commands n repeat n times, the same as i=(1,n,1)
!DO commands var=list repeat for elements in an array
!DO commands obey previous !SELECT (SH)

'commands' can be the name of a macro or commands within apostrophes.

5.3.3 !L, list or run previous commands


A number of previous commands (default=max 500) is maintained in the run time memory and they can be
listed or repeated with command !L. Examples of calls:
!L +n
list the n last commands
!L PLOT 5

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 42 (58)
General Tools and Functions

list the five last PLOT commands


!L 5 *
rerun the five last commands
!L SIZE *
rerun the last SIZE command

5.4 Commands related to list output


General functions related to listing are presented in chapter Listing and documents. Here is a short summary
of the most important transparent commands.

5.4.1 !PRINTER, default printer


Command !PRINTER selects the default printer:
!PRINTER name
The !PRINTER command also starts, ends direct hardcopy:
!PRINT ON/OFF

5.4.2 !PAGE, select page size


!PAGE sets the page height and width, according to which output is formatted:

!PAGE characters lines explicit size


!PAGE P according to the current printer
!PAGE A4H, A4V horizontal or vertical A4

5.4.3 !Header, control page headers


The !HEADER command selects the page headers to be output on every page.

5.4.4 !FORM, formatting of numbers


The !FORM command lists or changes the formatting of quantities: field length, number of decimals, unit, for
example:
!FORM X 7.0 MM
Sum rules and standard headers can also be changed with !FORM.

5.4.5 !LINK, redirect list output


The way to output a given listclass can be changed with command !LINK:
!LINK listclass dest1 dest2
'dest1' and 'dest2' designate the two possible destinations, for example:
!LINK R W F
output the result list to a separate text window and to the intermediate file.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 43 (58)
General Tools and Functions

5.5 Functions related to graphics


The function of graphics and the use of the commands listed below is presented in more detail in chapter
Graphics and drawing. Here, only a summary is given.

5.5.1 !GR, various control functions


The primary purpose of the command !GR is to select the output device and control the use of the IOF:

!GR device, !GR F, !GR


+F, !GR HERE

In addition, it provides various other service functions, of which those most likely to be needed are

!GR CLOSE finish graphics, close windows


!GR DRAW name; !GR EDR  
: open, close drawing
!GR UNDO remove the result of last output operation

5.5.2 !E, screen erase


Both the screen and the internal store are emptied.

5.5.3 !GIN, control of graphic input


The main functions related to graphic input are

!GIN DEC=nr control the accuracy of numbers obtained by graphic input


!GIN GRID more general way of controlling the accuracy
!GIN (u1,v1), define coordinate system on a tablet
(u2,v2),...
!GIN ON/OFF special function needed for VAXSTATION
!GIN !ECHO immediate echo of items input graphically

5.5.4 !VIEW, management of views


The !VIEW command handles functions related to the creating, deleting, visibility and properties of views, i.e.
independent parts of graphic output.

!VIEW nr create/select view


!VIEW 3D allow for automatic change of projection

Other aspects that can be controlled are storing of result, way of reacting to changed window size, and the
selection of the window.

5.5.5 !WINDOW, create window


With the !WINDOW command new windows for graphic output can be created and existing ones deleted or
resized. In connection to creating a new view, a window can also be created.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 44 (58)
General Tools and Functions

5.5.6 !LAYER create/change layer


A layer is part of a drawing that can be made visible independently of the others. The !LAYER command
creates new layers, changes the current layer (the one receiving the graphic output) and changes the visibility
of the layers.

5.5.7 !ZOOM, !PAN


The !ZOOM command shows part of a view enlarged so that it fills the window. The area to be zoomed can
be defined in the projection (2D zoom) or in the ship coordinate system (3D zoom). The 3D zoom can be
maintained even if the projection is changed. The 2D zoom can be given by dragging with the cursor after
entering !ZOOM I.
!PAN moves the zoomed area without changing the enlargement. There is an interactive version of !PAN,
started by !PAN I.

5.5.8 !SEND output of current graphics


Command !SEND sends the contents of the current view to the printer. It can also be used for storing the view
in the database, in the intermediate output file or in a file for use by another system:
!SEN TO printer
!SEND TO DB
!SEND TO IOF
!SEND TO system (e.g. DXF)
When sending to the printer, the default is to make an image of the window as it presently looks like, for
instance, after setting a zoom. With option D (drawing), the current drawing is sent regardless of how it is
presented on the screen.

5.5.9 !GRPAGE, drawing area


When scaling graphics according to the available area (SIZE, SETUP), the area used is normally the whole
window or screen. Occasionally it can be useful to force a drawing into a smaller area, which can be set with
!GRPAGE. This command also tells the size of the current drawing area when given without parameters.

5.6 Doing catalogs and selections


There is a general function for doing selections of objects in the database. The bare selection function is
available as the !SELECT command, which returns the result as an array that can be used by macros. The
same functionality is available by the service function AD.SELECT. The general selection function is also the
basis for the CATALOG function, available in most applications. The main output of this function is a list of the
selected objects, but an array is also created.

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.

5.6.1 !SELECT command


The purpose of the !SELECT command is to select a set of database objects and return a list of them that
can be used for controlling other functions. The following is a simple example, where all curves in the current
version are plotted:
!SELECT TYPE=C

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 45 (58)
General Tools and Functions

!DO 'PLOT %NAME' NAME=LIST


LIST is the default name of the array produced by !SELECT. In most cases, the !SELECT command is as
simple as in the example above, although its presentation is quite long because of the many options available.
The database used is by default the project database. Other databases can be selected as the first item,
either PROJDB (main project database, the default), AUXDB (the auxiliary project database), SYSDB (system
database), NAPADB (NAPA database) or DB1...DB7 giving the database unit directly.
The other options in !SELECT are either part of the selection criterion or control the way the result is delivered.
The selection criterion can contain three types of criteria:
■ selection based on database attributes: NAME, VERSION, DATE and TYPE
■ special criteria
■ occurrence of given strings
■ reference to given objects
■ user who wrote
■ selection based on arbitrary quantities in the descriptions

The last alternative is consistently available in SH only. This so-called quantity criterion is entered after the
others separated by a minus sign.

5.6.1.1 Database criterion


The database criterion is expressed by the general selection syntax presented below, using the quantities
NAME, VER, TYPE and DATE exactly as in the !CATALOG command. Examples:
!SELECT VER=(A,B,C) NAME>FR
!SELECT TYPE=G DATE>960101
!SELECT NAME>LD*CON

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.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 46 (58)
General Tools and Functions

5.6.1.2 LOC criterion


Occurrence of given strings can be tested for with the LOC criterion.
The LOC criterion can be applied in three ways

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)

5.6.1.3 REF criterion


Objects dependent on given ones can be selected with the REF criterion:
REF=name
REF=(name1,name2,..)
The REF criterion implies TYPE=G, i.e. geometric objects only. The following example selects all rooms
referring to HULL or its parts:
!SELECT TYPE=R REF=(HULL,HULLA,HULLM,HULLF)

5.6.1.4 USER criterion


Objects can be selected on the basis of the user who wrote it by the USER criterion:
USER=sign
The following example selects all curves last changed by JVH:
!SELECT TYPE=C USER=JVH
Common properties of the LOC, REF and USER criteria:
In all these criteria, multiple alternatives can be given as a list in parentheses, as shown in the examples above.
A list of strings can be given by a calculator array using the syntax name(). The reference example could be
made this way (under the DEF task):
SELECT *HULL
!SELECT TYPE=R REF=LIST()
LIST is an array produced by SELECT, containing HULL and its parts.
The criteria can be negated by adding a minus sign in front of the identifier, for example
!SELECT NAME>DATA* -LOC<HULL
selecting all macros not involving the text HULL.

Note: there can be only one subcriterion of each kind.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 47 (58)
General Tools and Functions

5.6.1.5 Quantity criterion


The so-called quantity criterion uses values of quantities, as stored within the descriptions. This requires that
they are stored each in its own record, having the standard record number. This principle is applied consistently
in SH and IS but not in other parts of NAPA. This criterion is therefore available under SH and IS only. The
criterion is expressed by the general selection syntax, for example
!SELECT NAME>SHM* - PE>8000 L=(100...200)
Note the minus sign that separates this criterion from the database criterion.

5.6.1.6 Options telling how to return the result


The following options influence the way the result of the selection is returned.
Option L gives a list of objects at the execution of !SELECT; otherwise, it can be obtained by !VAR LIST LIST.
->array
This option gives the name of the array by which the list of objects is returned, the default of which is LIST. The
following example stores a list of rooms in an array named ROOMS:
!SELECT TYPE=R ->ROOMS
If the selection involves multiple versions, another array is created containing the versions, named by adding
V in front of the name of the main array, for example
!SELECT NAME>HULL ->HULLS ALL
giving arrays HULLS and VHULLS.
Additional information in own arrays is obtained by the following options:

U sign of user in array ULIST


D dates in array DLIST
T types in array TLIST (integers)

The name component LIST is changed if the -> option is given.


Sorting is obtained by options SORT (by name) SORTD (by date) and SORTV (by version).
The result of the selection can also be available in a table that can be further processed under table calculation.
The option for this is TABLE=name, where 'name' is the name of the table created. The name can be omitted,
then a table named TABLE is created. The options U, D and T affect the table also. Example:
!SELECT NAME>FR D U TABLE=FRAMES
TAB
GET FRAMES
P A
NAME DAT VERS ID
--------------------------------------------
FRA 999381409 A JVH
FRA7 999381413 A JVH
FRA4 999381411 A JVH
FRA1 999381413 A JVH
FRF5 999381411 A JVH
FRF3 1016959101 A JVH
FRA6 1016928194 A JVH
...
FRA2 999381413 A JVH

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 48 (58)
General Tools and Functions

FRA3 999381408 A JVH


FRF4 999381411 A JVH
The date is here in the internal form. The calculator functions DATE, TIME and FDATE, FTIME convert the
internal form to more readable forms.

5.6.2 General CATALOG function


In most applications there is a CATALOG command for listing objects stored in the database and belonging
to the application, for example, loading conditions. Most of these use the general catalog function presented
here. There are a few cases where it has not been installed because of some special service produced by
the original catalog function.
This function is in most respects identical with !SELECT, except for the following differences:
■ the application assigns the database prefix corresponding to the current subject as part of the selection
criterion. In the output, the prefix is not shown and selection criteria are expressed without it.
■ the output is a listing of objects
■ if there is a descriptive text available for the object type, it is included
■ the size of the descriptions can be included in the output
■ the list of objects is available in an array also, in this case the array is named CATALOG
■ the catalog can be done from a different project or version
■ there is a COPY option by which selected objects can be copied to the current project and version
The special logic related to the database prefix is available in !SELECT also, and presented below.
The following is an example of output, taken from CAT LOAD in LD:
Name Description Date Time
LOAD1 Light Ship (A) 95-09-01 22.03
LOAD2 Ballast Condition 95-09-01 22.03
LOAD3 Grain Cargo 95-09-01 22.03
LOAD4 Mass loads 95-09-01 22.03
T One mass load 96-01-01 19.22
The general catalog function was introduced in Release 94.1. In most cases, it has replaced the old catalog
function but in some cases, the functionality of the old function has been maintained in parallel, most important
in the Editor and in task TOC. Usually, the correct function can be selected on the basis of the options, but in the
Editor, the option GEN may be needed to force the use of the new function. The following example illustrates
this and at the same time, listing description sizes:
CAT NAME>B SORTN SB GEN
BJTAB 96-02-28 22.40 1252
B-PROFILES 95-11-23 15.42 552
BRACKETS 95-11-23 15.41 796
BULBPROF 95-11-23 13.41 1708
Size total: 4308
SB stands for size in bytes. There is the alternative SR, size in records, referring to the number of records
needed in the database.
The following example shows the same objects, but the catalog is made under another project.
CAT NAME>B SORTN PROJECT=D-STAR-K REX
Catalog from project D-STAR-K
=============================
Name Version Date Time Exist
BJTAB A 96-02-28 22.40 *
B-PROFILES A 95-11-23 15.42 -

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 49 (58)
General Tools and Functions

BRACKETS A 95-11-23 15.41 -


BULBPROF A 95-11-23 13.41 -
The option REX stands for 'record existence', and gives the rightmost column where an asterisk shows that
an object with the same name exists in the current project also. This is a useful check before doing copying
with option COPY.

5.6.3 Copying data from other projects and versions


A completely general service for copying data is provided by command COPY under TOC. Copying can also be
done with the general CATALOG command. Compared to TOC, the CAT command offers more possibilities to
control the result. Copying is bundled with CATALOG because CATALOG provides exactly the service needed
for managing the copying and the CAT function is already installed in a large number of contexts.
Copying is done by adding option COPY. The operation is done in two steps: first a catalog similar to the one
listed above is displayed. Before continuing with the actual copying, permission is asked. This question can
be suppressed with option NQ. Example:
CAT NAME>B VER=A PROJECT=D-STAR-K COPY
The VER criterion is compulsory. By default, only objects not existing before are copied. In this example, the
macro BJTAB would not be copied. With COPY! instead of COPY, objects are copied without regard to previous
existence.

Note: for copying geometric objects, the command COPY in DEF is recommended. It provides the service
related to referenced objects.

5.6.4 !CATALOG command


The transparent catalog command has the same functionality as the simple CATALOG command in the TOC
task: listing database objects using a criterion involving name, version, type and date, exactly as in the
corresponding part of !SELECT. There is no predefined restriction to the current version. Example:
!CAT VER=A NAME>FR
The database unit can be given as the first parameter.

5.6.5 Database prefix


Geometric objects are stored in the database under the name used in the definitions. All other objects are
identified by a database prefix. The following list gives some of the most important ones:

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

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 50 (58)
General Tools and Functions

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

5.6.6 General selection syntax


The database and quantity criteria in !SELECT are expressed using the so-called standard selection syntax.
The same syntax is used in a large number of other places in NAPA, for example, in TOO, SUBSET in TAB,
SELECT in CP, SM, and LD. The criterion is composed of subcriteria, each comparing the value of a quantity
to a given value, range or list of values. For numbers, the normal operators are used, for example:

ZMIN=0 equality
ZMIN>5 larger than
ZMIN<2 smaller than
ZMIN=2.5...4 range

For string quantities, the operators are interpreted as follows

NAME=HULL equality
NAME>HULL begins with
NAME<HULL contains

Several alternatives can be given as a list in parentheses, for example


NAME=(HULL,HULLA,HULLM,HULLF)
The alternatives can also be given by an array:
NAME=LIST()
In the case of a string equality, the given string may form a filter. A filter is expressed by a string containing
wildcards. The wildcard characters are
*: matches any number of characters (also 0)
?: matches one, arbitrary character

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 51 (58)
General Tools and Functions

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:

-NAME>HULL name does NOT begin with HULL

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

5.7 Functions related to the calculator


The calculator and NAPA BASIC are presented in more detail in their own chapters. For more information,
please refer to the following chapters: Calculator, Programming macros (NAPA BASIC) and NAPA BASIC
commands. Here, only a short presentation of the related commands is given.

5.7.1 Command !CALC, evaluate expression


The central command is !CALC, which evaluates an expression, for example
!CALC TAN(10.5/LREF)
!CALC VOL('HULL',2.5)
The result can be assigned to a variable, for example
!CALC CB=VOL('HULL',5)/(LREF*BDWL*5)
The calculation can be repeated for all elements in an array, for example
!CALC MOM()=MASS()*X()
where MOM, MASS and X are arrays. A bare copying of an array can be done in the form:
!CALC B()=A()
The explanation of !CALC contains a short presentation of the NAPA specific calculator functions.
If one has interrupted a macro having local variables, their values are no longer available the normal way, but
can be examined by adding option * to !CALC, for example
!CALC I *
This gives the value of the variable I in the interrupted macro.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 52 (58)
General Tools and Functions

5.7.2 Command !VAR, services related to the calculator


Command !VAR provides various services related to the calculator. The following commands set control related
to variables:

!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.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 53 (58)
General Tools and Functions

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.

5.7.3 Output function


The command !OUTPUT is provided specifically to be used as output function for macros. It is otherwise
equivalent with !TYPE, but while !TYPE writes to the log (list class 4), !OUTPUT uses list class 3. The output
can therefore be controlled independently of the log with command !LINK 3 ...;.
There is also the command !INPUT, but this has been replaced with the calculator function INPUT, which is
more convenient.

5.8 Control related to calculations and geometry


The commands !TOL, !GMTP, SECWL INTOL and !ECO allow the setting of various operation modes or
tolerances concerning geometry and calculations. For more information on their meaning, see the documents
on geometry and calculations. These commands are usually not needed in normal work and some parameters
(!ECO, !GMTP) have been provided mainly for compatibility with older releases. See also the reference system.
Occasionally one may need
!TOL polygonization tolerance
This command sets the tolerance controlling how many points are used for representing curves. Typical values
are 0.001...0.01. When making curves in a specially large scale, one may need a tighter tolerance.

5.9 Functions related to file i/o and management

5.9.1 Opening and closing files


NAPA normally opens and closes automatically the files or databases needed. For special cases, the opening
and optionally creating of a file can be done at a user command. This is possible for both NAPA databases and
for ordinary ASCII files. These cases are distinguished by the unit number occurring in the opening command:
!OPEN directory>file unit
!OPEN project unit
In the first case, the file is designated directly by its name under the operating system. 'directory' means all
parts of the pathname except the file name. In the latter case, 'project' is the name of a NAPA project and the
file name is found from the project administration.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 54 (58)
General Tools and Functions

'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

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 55 (58)
General Tools and Functions

The PARSE function has been provided for accessing parts of a text string, and it may be useful when
interpreting file contents.

5.9.2 Reading and writing environmental variables


Command !ENV handles environmental variables:

$$(!ENV) !ENV name print the value of the given variable


!ENV name=value assign a value to the given variable

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.9.3 Other commands


The following commands are less likely to be needed, but they are listed here for information.
!IOC i/o control for databases
This refers to a feature in the database management that is analogical with the list class in alphanumeric output.
In the same way as lists are divided into list classes, data is divided into data classes. The !IOC command
allows the association between data classes and databases to differ from the normal one.
!ATTACH file attach point
This command makes a temporary modification to the parameter ATTACH in the installation parameters. The
use of this parameter allows relative file names to be fixed to a given directory rather than being dependent
on the default directory assigned outside NAPA.
!VERSION change version
The !VERSION command changes version as far as database i/o is concerned. This can have unpredictable
effects and it is allowed only if the full professional mode is on. Command !VER LIST is available without
restriction.
!ENL enlarge database
This command was added to allow the enlargement of the database without interrupting the current task. As
the restriction imposed on the database size has been lifted in practice, this command is not needed.
!PREFIX
This is the same function as handled by command PREFIX in the Editor, controlling reading of macros. It is
provided as a transparent command so that the control of the prefix can be done in INIT* and TINIT* macros.

5.10 Commands related to system development


The main purpose of the following commands is to assist in system development and they are listed here for
information only.
!TRACE set trace parameter
The trace parameter provides a way for the system developer to switch on and off various output functions
or alternative operating modes.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 56 (58)
General Tools and Functions

!DML list description


This command lists a description, i.e. a database object in terms of its own structural components.
!MAP list contents of the free storage
The free storage is the place where descriptions are held at run time. !MAP gives a short summary of its named
contents.
!STATUS list the state of usage of the free storage
!TEST set test mode
In the test mode, the internal error messages between subroutines are visible and a system error does not
interrupt the run.

5.11 Various functions

5.11.1 Output to the log


Command !TYPE writes text to the log (listclass 4). The input is printed exactly as given in the TYPE command.
There is also the !OUTPUT command which is otherwise similar, but it uses listclass 3, and it can therefore be
controlled independently of the log (command !LINK).

5.11.2 Pause
Command !PAUSE makes the system wait for a specified time.

5.11.3 Command !BELL


Command !BELL produces a beep from the terminal or workstation and writes asterisks to the screen. The
typical use of this function is to call attention when a long calculation is finished.

5.11.4 Assigning full profession mode


With command !PRF F, you can get access to functions needing full professional mode even if you are not
registered this way. This can be prevented by defining a password (see system maintenance functions).

Note: full professional mode implies administrator rights only when no administrator has been declared in
the installation parameters.

5.11.5 Creating private lists


With command !PRL, you can make subsequent lists and plots private, i.e. not accessible in SCAN or PLOT
by other users. The output is private by default if the version is private.

5.11.6 Assigning actions to events


The command !ACTIONS was released with pilot status in Release 96.1. It defines actions to be done in given
connections called events. The actions are defined by commands to be carried out, given either directly or
via a macro.
Events are not yet consistently available - the implementation has mainly followed that of the graphical user
interface. Some examples are:

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 57 (58)
General Tools and Functions

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.

5.11.7 Assigning terminal properties


The primary function of command !TERM is to define the type of terminal used, in case the original decision
taken by the monitor was not correct. This type is defined by the name of a device declared in the installation
parameters.
The !TERM command can also be used for instructing the system how to interpret input from a table, either by
assigning a predefined type or by providing a template for the table output. This function is usually not needed
in present configurations.

5.12 Transparent services for GM, SM and TAB


Some functions of GM (geometry), SM (ship model) and TAB (table calculation) are available as transparent
commands, in order to make them generally available. Most of these are intended for special cases only. The
following commands are the most important ones; for the rest, see the command explanations.

!SM (no parameters) Tells the current arrangement.


!GM DES name Lists the definition of the given object.
!GM INFO name Gives the same output as the INFO command of DEF. The LQ can
be changed by !GM LQ ...; for example, !GM LQ EC; for extreme
coordinates.
!GM GET name/vers/ Makes an object from a different project or version available for graphic
project output or other output functions.
!TAB GET name variable Gets a table into memory and optionally stores a reference into a given
variable.
!TAB LIST Lists tables in memory, including a flag on tables changed but not stored.
!TAB WA LIST Lists all work areas.

5.13 Command specifications


The command explanations related to the subjects of this chapter are collected separately for practical reasons.
They are grouped the same way as the subjects in the text. Transparent commands not presented in this
chapter are mentioned.

© 1992-2011 Napa Ltd. All rights reserved.


NAPA Online Manuals 2011.2 58 (58)
General Tools and Functions

5.13.1 Help functions

5.13.2 Commands producing information

5.13.3 Catalogs and selections

5.13.4 Functions related to the calculator

5.13.5 Control of calculations and geometry

5.13.6 Functions related to file i/O

5.14 Commands for development and maintenance

5.14.1 Various commands

5.14.2 Transparent services from GM, SM, TAB

© 1992-2011 Napa Ltd. All rights reserved.

You might also like