contents.gifprev1.gifnext1.gif

Data Types

nu/TPU contains the following data types:

tpu90000.gif ARRAY

tpu90000.gif BUFFER

tpu90000.gif INTEGER

tpu90000.gif KEYWORD

tpu90000.gif LEARN

tpu90000.gif MARKER

tpu90000.gif PATTERN

tpu90000.gif PROCESS

tpu90000.gif PROGRAM

tpu90000.gif RANGE

tpu90000.gif STRING

tpu90000.gif UNSPECIFIED

tpu90000.gif WIDGET

tpu90000.gif WINDOW

Each of the data types listed above is a nu/TPU keyword. Each data type represents a group of related variables that are created and act in a consistent manner to each other. Each variable created is assigned a data type to determine the operations that can be performed with the variable. Without the data type assignment, nu/TPU would be unable to determine the type of data contained by the variable. nu/TPU does not use declaration or definition statements to assign a variable as a specific data type. Once a variable is created, its data type may be changed as many times as needed. nu/TPU does not require that variables be assigned a specific type prior to being used.

The nu/TPU language allows variable data types to be changed, but the data type of a variable passed to a built-in must match the parameter specification for the built-in.

Array

Arrays are lists of related items. An array element may be used wherever a variable is valid. The built-in functions CREATE_ARRAY, DELETE, and GET_INFO return array types. The following is a list of array characteristics:

Single array elements have the form: array_name {index}

Arrays can contain both fixed and dynamic elements. The fixed elements are only created by CREATE_ARRAY.

The optional fixed portion can contain no more than 2(32-1) -1 elements.

The fixed portion is declared during a call to the CREATE_ARRAY built-in.

The index to the fixed elements must be an integer constant and may start at any number.

The optional dynamic elements are created by assignment statements.

The indexes to the dynamic elements may be any value.

The elements of an array may be any data type.

Array elements do not have to be the same data type.

Arrays may contain 0 elements.

Array definitions consist of the array name and the array index. For example, the following is a valid array statement:

X := FAMILY {4}

In the above, we are assigning the value referenced by the index value of 4 in the array FAMILY to a variable X.

Buffer

Buffers contain both text to be manipulated and various control elements to assist user editing. The built-in functions returning elements of buffer type are CREATE_BUFFER, GET_INFO, and CURRENT_ BUFFER. Once a buffer is created, only the DELETE built-in function will remove it. The text in a buffer can be removed with the ERASE built-in. The number of lines and the size of a buffer is limited to available memory. For the text in a buffer to be visible in nu/TPU, the buffer must be mapped to a window. Buffers can be mapped to an unlimited number of windows simultaneously.

Each of the buffer’s informational elements (listed below) is internal to the buffer variable itself and can be retrieved using the GET_INFO built-in.

Buffer variables contain the following informational elements:

tpu90000.gif buffer text

tpu90000.gif buffer name

tpu90000.gif editing point

tpu90000.gif end of buffer text

tpu90000.gif input filename

tpu90000.gif key-map-list

tpu90000.gif margin actions

tpu90000.gif margin settings

tpu90000.gif markers

tpu90000.gif maximum number of lines allowed in the buffer

tpu90000.gif modify or no_modify buffer toggle

tpu90000.gif permanent status

tpu90000.gif ranges

tpu90000.gif search direction (forward/reverse)

tpu90000.gif system status

tpu90000.gif tab settings

tpu90000.gif text entry mode (insert/overstrike)

tpu90000.gif window mappings

tpu90000.gif write or no_write when exiting nu/TPU

Any and all of the above internal informational elements can be both modified or determined with the SET and GET_INFO built-ins respectively.

Integer

A nu/TPU integer is any number from -2,147,483,648 to 2,147,483,647 inclusive but having no floating point or decimal data. nu/TPU integers contain only digits, no commas (,) or decimal points (.). Integers are stored as 32-bit data values.

Keyword

There are more than 1,300 keywords in nu/TPU. These keywords are integer constants which are designed to aid portability of programs and interfaces from one nu/TPU platform to the next.

The 1,300+ keywords can be broken down into three distinct groups: constants, nu/TPU error messages, and interface messages. Interface message keywords begin with “SI$_” or “EVE$_”. nu/TPU error message keywords begin with “TPU$_”.

The following are predefined constants:

FALSE

TPU$K_ALT_MODIFIED

TPU$K_CTRL_MODIFIED

TPU$K_HELP_MODIFIED

TPU$K_MESSAGE_FACILITY

TPU$K_MESSAGE_ID

TPU$K_MESSAGE_SEVERITY

TPU$K_MESSAGE_TEXT

TPU$K_SEARCH_CASE

TPU$K_SEARCH_DIACRITICAL

TPU$K_SHIFT_MODIFIED

TPU$K_UNSPECIFIED

TRUE

Keywords can be superseded by local variable definitions, but not redefined. Note that as soon as the local variable definition expires, the original keyword value is reinstated.

To list the nu/TPU keywords, use the SHOW (KEYWORDS) built-in or turn to Appendix B.

Learn

The learn data type is a collection of keystrokes. The built-in functions LEARN_ABORT, LEARN_BEGIN, and LEARN_END are used to build new learn sequences. Learn variables are created with the LEARN_END built-in. They are terminated with the LEARN_ABORT built-in or stored with the LEARN_END built-in. If a learn sequence is defined as EXACT, all input to the READ_CHAR, READ_KEY, and READ_LINE functions are replayed with the same keystrokes provided during the learn definition. If NOEXACT mode is used, the input built-ins prompt for new data when the learn is executed. Usually the learn variable is assigned to a specific key and is replayed as a “macro.”

A typical learn variable sequence is described below.

LEARN_BEGIN (NO_EXACT);

user_input keystrokes

user_learn := LEARN_END;

DEFINE_KEY (user_learn, KP5);

The first line in the above tells nu/TPU to start storing keystrokes to an as yet unnamed learn variable. Further, all input from any READ_LINE, READ_KEY, and READ_CHAR will be entered by the user when the learn variable is replayed.

The third line is where nu/TPU stores the value of the keystroke sequence to be replayed in the variable user_learn.

The fourth line tells nu/TPU to tie the learn variable value to the numeric keypad’s “5" key.

Marker

Markers are used to locate positions in a buffer. The markers can be FREE or BOUND.

A BOUND marker variable is associated with a single character in the text. As the character moves within the buffer, the associated BOUND marker variable moves with the character.

A FREE marker variable is also associated with a single character in the text but is offset from the character in the text to its location in one of the following types of white space: Before start of line, past end of line, middle of tab, or past end of buffer

NOTANY

Marker variables can have the following video attributes: None, Bold, Blink, Underline, Reverse, Black, Blue, Cyan, Green, Magenta, Red, White, and Yellow. Marker variables are deleted when all references to them are set to 0 or deleted. They do not remain active nor are they stored between editing sessions.

The following built-ins work with markers: BEGINNING_OF, MARK, DELETE, SELECT, END_OF, GET_INFO, and CREATE_ RANGE.

Pattern

Pattern variables are used by the built-ins SEARCH and SEARCH_ QUIETLY. The patterns themselves are constructed from strings, string variables, keywords, other patterns, and pattern built-in functions. Complex patterns are formed by combining pattern elements and the four pattern operators (+,&,|, and @). In a search, the pattern is the master template that the search tries to match.

Pattern Built-ins

Pattern built-ins can be used with strings and pattern operators when creating patterns. Search direction and type are set by the parameters to the SEARCH built-in function. All nu/TPU pattern built-ins, listed below. Additional information is provided in the built-in section of this reference manual.

ANCHOR

ANY

ARB

BUFFER_BEGIN

BUFFER_END

LINE_BEGIN

LINE_END

NOTANY

MATCH

REMAIN

SCAN

SCANL

SPAN

SPANL

UNANCHOR

Pattern Built-in Error Conditions and Messages

The following list contains all the error messages and conditions you might encounter when using a pattern built-in.

Error Description

TPU$_ARGMISMATCH The pattern’s argument is an incorrect data type.

TPU$_CONTROLC The [CRTL-C] keystroke combination was typed during the execution of the built-in.

TPU$_INVPARAM The pattern’s argument is an incorrect data type.

TPU$_MINVALUE The pattern’s argument is less than the minimum accepted value.

TPU$_NEEDTOASSIGN The return value from the built-in must be used.

TPU$_TOOFEW There must be at least one argument for the pattern built-in.

TPU$_TOOMANY There can be no more than two arguments for the pattern built-in.

Using Pattern Built-ins and Keywords

A pattern is any valid nu/TPU structure which can be used when searching for text in a given buffer. Essentially, “patterns” are templates used by nu/TPU to find strings and patterns of character values in text. How specific the search is depends entirely on the template used. Patterns can be created by any of the following:

tpu90000.gif String constants

tpu90000.gif String variables

tpu90000.gif Pattern variables

tpu90000.gif Calls to pattern built-ins returning a string or pattern value

tpu90000.gif () used to enclose expressions

tpu90000.gif Pattern keywords

The above can be used separately or linked together with any pattern operators (+,&,|, or @). The pattern concatenation operator (+) anchors two pattern specifications together. For a match to be successful, the right pattern element must immediately follow the left pattern element. The pattern linking operator (&) may create anchored or unanchored patterns. When a pattern element is linked to a pattern or keyword variable, it is an anchored search. When nonpattern elements are linked, by default they are unanchored. The pattern alternation operator (|) allows a search to be successful if it finds either of the pattern elements separated by the operator. The partial pattern assignment operator (@) instructs a search to create a range matching pattern elements to the left of the operator, leaving the elements on the right to reference this range.

Simple patterns can be created by using either string constants or variables. For example:

SIMPLE_PATTERN := “simple pattern”

Similarly, you can use some of the string operators to create a not-so-simple pattern such as:

NOTSOSIMPLE_PATTERN := “simple” | “pattern”

The above tells nu/TPU to match either “simple” or “pattern.” The above should not be confused with a string variable. A string variable using the same text arguments would be:

SIMPLE_PATTERN := “simple” + “ ” + “pattern”

The above creates a string variable, SIMPLE_PATTERN, with the value “simple pattern.” NOTSOSIMPLE_PATTERN is a pattern used with the SEARCH built-ins to look for either of the strings “simple” or “pattern,” not the string value “simple pattern.” Note that SEARCH and its inconspicuous twin, SEARCH_QUIETLY, can make use of both patterns and string variables.

Still more complex patterns can be created by using simple strings and pattern operators. An example might be:

MORECOMPLEX_PATTERN := “simple” + SPAN (“pattern”)

The above tells nu/TPU to look for text that looks like any of the following:

simplepattern

simplepatter

simplepatte

simplepatt

simplepat

simplepa

simplep

simpleattern

simpletern

It goes on from there. The fact is, the above listed example tells nu/TPU to look for anything that begins with “simple” and is immediately followed by any of the characters in “pattern,” provided the characters in ‘pattern’ don’t go over to the next line of text.

To further demonstrate the possibilities available when building patterns, any of the following are valid.

PATTERN1 := ANY (“ABCDEFG”)

PATTERN2 := LINE_BEGIN + REMAIN

PATTERN3 := PATTERN1 + “can’t find me”

PATTERN4 := “where are you” @ PATTERN3

PATTERN5 := “first part” & “second part”

! EVE section file example:

! Space and Tab

CONSTANT EVE$KT_WHITESPACE := “ ” + ASCII (9);

! Word separators: Space, HT, FF, CR, VT, LF

CONSTANT EVE$$X_WORD_SEPARATORS := “ ” + ASCII (9) + ASCII (12) +

ASCII (13) + ASCII (11) + ASCII (10);

! End of word

EVE$PATTERN_END_OF_WORD := (ANCHOR + (LINE_END

| (SPAN (EVE$KT_WHITESPACE)

+ (ANY (EVE$$X_WORD_SEPARATORS) | “”)))

| ANY (EVE$$X_WORD_SEPARATORS)

| SCAN (EVE$$X_WORD_SEPARATORS)

| REMAIN)+ (LINE_BEGIN |SPAN (EVE$KT_WHITESPACE) |"");

Process

Process data types contain information internal to nu/TPU which deals with spawned processes simultaneously with a nu/TPU session. nu/TPU provides limited access to other processes created from or running concurrently with a nu/TPU session. It is not advisable to mix full screen or highly interactive programs within a nu/TPU session.

Program

Program data types contain compiled nu/TPU procedures and statements. Programs can contain one or more procedures and statements, and are used in key definitions, command lines, and stand-alone. The built-ins using program data types are COMPILE, EXECUTE, and LOOKUP_KEY.

my_exec := compile (my.tpu);

This example compiles the nu/TPU code in the buffer my.tpu and assigns the result to variable my_exec, which is then assigned as a program data type.

Given that my.tpu contains valid nu/TPU code, all the commands and functions in the buffer are rewritten in a compiled form and stored in the variable my_exec. You can then execute my_exec with the command:

EXECUTE (my_exec)

The above command causes all the compiled code in the program data type variable my_exec to run.

Range

A range contains all the text between two markers inclusive. Ranges are created with the CREATE_RANGE built-in. The markers used to create the range do not need to be created or positioned in any specific order. Ranges can have video attributes assigned to them.

Built-in functions that return range data types are: CHANGE_CASE, CREATE_RANGE, EDIT, GET_INFO, MODIFY_RANGE, SEARCH, SEARCH_QUIETLY, SELECT_RANGE, and TRANSLATE. Ranges can be deleted without affecting the text between the start and end markers by using the DELETE built-in. Text associated with a range must be removed with the ERASE built-in.

my_range := create_range (mark (none), old_mark, bold);

Create a range data type variable my_range which includes the text from the current edit position to the location defined by the old_mark variable. The video attribute assigned to my_range is BOLD.

ERASE (my_range);

removes all of the text located with my_range.

DELETE (my_range);

deletes the my_range variable. The content of any text associated with my_range would not be altered. The video attributes assigned during the range creation would be removed.

String

A string is a list of ASCII characters, delimited by a pair of single (‘) or double (“) quotes. Strings may contain any valid ASCII characters including control characters. Strings can contain from 0 to 255 characters.

When a set of characters is enclosed in quotes, it is defined as a string. Strings may also contain the quote characters used as the delimiter if the quote character is repeated within the string. The result of the following example is the string, “It’s a wonderful product.” assigned to my_str.

my_str := “”"It’s a wonderful product."""; ! 3 leading & trailing double quotes.

my_str:= ‘"It’s a wonderful product."’;

Strings may be created from range and buffer text using the STR and SUBSTR built-ins.

Unlike most languages, strings can be used in multiplication operations to replicate the string x number of times.

new_str:= (‘abc’ * 3);

The resulting assignment for new_str is ‘abcabcabc’.

Unspecified

Unspecified data type is assigned to global variables before execution or any explicit value assignment. All assignments result in a data type assigned, except when an assignment is to the keyword TPU$K_UNSPECIFIED. A variable must be assigned a value prior to use as a built-in argument. When you create a procedure and initialize variables without values, they are assigned as unspecified variables.

Widget

The widget data type is provided for nu/TPU to support X and MS Windows activity. Widgets are used to pass information between the window manager and nu/TPU application.

Defining how widgets are used in X or MS Windows is beyond the scope of this reference manual. Before using widget data types in the nu/TPU language, you should be familiar with coding widgets in your target windows environment.

Widgets are created with the CREATE_WIDGET built-in. To delete the widget structure, use the DELETE built-in. Simply removing the reference to a widget will not delete it.

Widgets may not be used with arithmetic or relational operators with the exception of equality and inequality operators (=,<, >) to test if two widget instances are the same.

Window

Window variables are much like buffer variables. They are unique entities which incorporate internal discrete information elements. These information elements determine how and what information is to be displayed for specific sections of the screen. A window may be defined to use a portion of or the entire screen to display the contents of a buffer.

Windows are created with the CREATE_WINDOW built-in. The window does not become visible until it is tied to a buffer with the MAP built-in. The maximum length that may be defined when creating a window is limited to the size of your physical window. If your terminal supports a maximum of 24 lines, the longest nu/TPU window that can be defined is 24 lines. Windows may occlude other windows by overlapping them. Windows can be removed from view with the UNMAP and DELETE built-ins.

The following built-ins are used with the window data types: ADJUST, CREATE_WINDOW, DELETE, GET_INFO, MAP, REFRESH, SET, SHOW, UNMAP, and UPDATE.