HP OpenVMS Systems Documentation
Guide to the DEC Text Processing Utility
3.4 Keyword Data Type
Keywords are reserved words in DECTPU that have special meaning to the compiler.
To see a list of all DECTPU keywords, use the SHOW (KEYWORDS) built-in.
Table 3-1 shows the correspondence between keywords used as DECTPU key names and the keys on the VT400, VT300, VT200, and VT100 series of keyboards. You do not have to define a key or control sequence just because there is a DECTPU keyword for the key or sequence.
1Ctrl/A means pressing the Ctrl key simultaneously with the A key. A and a produce the same results.
The OpenVMS terminal driver handles the following keys as special cases. Compaq recommends that you avoid defining the following control characters and function key:
3.5 Learn Data Type
A learn sequence is a collection of DECTPU keystrokes for use later. The LEARN_BEGIN built-in procedure starts collecting keystrokes; the LEARN_END built-in procedure stops the collection of keystrokes and returns a value of the learn data type as a result. The following example assigns a learn data type to the variable x:
All keystrokes that you enter between the LEARN_BEGIN and LEARN_END built-in procedures are stored in the variable x. The EXACT keyword specifies that, when the learn sequence is replayed, the input (if any) for the built-in procedures READ_CHAR, READ_KEY, and READ_LINE (if used in the learn sequence) will be the same as the input entered when the learn sequence was created. If you specify NO_EXACT, a replay of a learn sequence containing keys that invoke the built-in procedures READ_LINE, READ_KEY, or READ_CHAR looks for new input.
For more information on replaying a learn sequence, see LEARN_BEGIN and LEARN_END in the DEC Text Processing Utility Reference Manual.
You can use the LEARN_ABORT built-in procedure to interrupt the execution of a learn sequence. For information on using LEARN_ABORT, see LEARN_ABORT in the DEC Text Processing Utility Reference Manual.
To enable your user-written DECTPU procedures to work successfully with learn sequences, you must observe the following coding rules when you write procedures that you or someone else can bind to a key:
These practices help prevent a learn sequence from finishing if the learn sequence calls the user-written procedure and the procedure is not executed successfully.
A procedure that does not explicitly return a value returns 0 by default, thus aborting a learn sequence.
3.6 Marker Data Type
A marker is a reference point in a buffer. You can think of a marker as a "place holder." To create a marker, use the MARK built-in procedure.
The following example assigns a value of the marker data type to the variable x:
After this statement is executed, the variable x contains the character position where the editing point was located when the statement was executed. The editing point is the point in a buffer at which most editing operations are carried out.
You can cause a marker to be displayed with varying video attributes (BLINK, BOLD, REVERSE, UNDERLINE). The NONE keyword in the preceding example specifies that the marker does not have any video attributes.
When you use the MARK built-in, DECTPU puts the marker on the buffer's editing point. The editing point is not necessarily the same as the window's cursor position.
A marker can be either free or bound. Free markers are useful for establishing place marks in locations that do not contain characters, such as locations before the beginning of a line, after the end of a line, in the white space created by a tab, or below the end of a buffer. By placing a free marker in such a location, you make it possible to establish the editing point at that location without inserting padding space characters that could complicate later operations such as FILL.
A marker is bound if there is a character in the position marked by the editing point at the time you create the marker. A bound marker is tied to the character on which it is created. If you move the character to which a marker is bound, the marker moves with the character. If you delete the character to which a marker is bound, DECTPU binds the marker to the nearest character or to the end of the line if that is closer than any character.
To force the creation of a bound marker, use the MARK built-in with any of its parameters except FREE_CURSOR. This operation creates a bound marker even if the editing point is beyond the end of a line, before the beginning of a line, in the middle of a tab, or beyond the end of a buffer. To create a bound marker in a location where there is no character, DECTPU fills the space between the marker and the nearest character with padding space characters.
A marker is usually free if all of the following conditions are true:
The following paragraphs explain each of these conditions in more detail.
If you use the MARK (FREE_CURSOR) built-in procedure and there is a character in the position marked by the editing point, the marker is bound even though you specify otherwise. Once a marker becomes bound, it remains bound throughout its existence. To determine whether a marker is bound, use the following GET_INFO call:
DECTPU keeps track of the location of a free marker by measuring the distance between the marker and the character nearest to the marker. If you move the character from which DECTPU measures distance to a free marker, the marker moves too. DECTPU preserves a uniform distance between the character and the marker. If you collapse white space that contains one or more free markers (for example, if you delete a tab or use the APPEND_LINE built-in procedure), DECTPU preserves the markers and binds them to the nearest character.
If you use the POSITION built-in procedure to establish the editing point at a free marker, the marker remains free and the editing point is also said to be free; that is, the editing point is not bound to a character. Some operations cause DECTPU to fill the space between a free marker and the nearest character with padding space characters, thereby converting the free marker to a bound marker. For example, if you type text into the buffer when the editing point is detached, DECTPU inserts padding space characters between the nearest character and the editing point. Using any of the following built-in procedures when the editing point is detached also causes DECTPU to perform padding:
Example 3-1 shows how to suppress padding while using these built-ins. The example assumes that the editing point is free. The code in this example assigns the string representation of the current line to the variable bat without adding padding blanks to the buffer.
You can also set all variables referring to the marker to refer to something else, for example, tpu$k_unspecified or 0. The following statement sets the variable mark1 to 0:
If mark1 were the only variable referring to a marker, that marker would be deleted upon execution of the previous statement.
The marker data type is returned by the MARK, SELECT, BEGINNING_OF,
END_OF, and GET_INFO built-in procedures.
A pattern is a structure that DECTPU uses when it searches for text in a buffer. You can think of a pattern as a template that DECTPU compares to the searched text, looking for a match between the pattern and the searched text. You can use a variable whose data type is the pattern data type when you specify the first parameter to the SEARCH and SEARCH_QUIETLY built-in procedures.
To create a pattern, use DECTPU pattern operators (+, &, |, @) to connect any of the following:
Patterns can be simple or complex. A simple pattern can be composed of sets of strings connected by one of the pattern operators. The following example indicates that pat1 matches either the string "abc" or the string "def":
If you connect two strings with the + operator, the result is a string rather than a pattern. For example, the following statement gives pat1 the string data type:
The SEARCH and SEARCH_QUIETLY built-in procedures accept such a string as a parameter.
A more complex pattern uses pattern built-in procedures and existing patterns to form a new pattern. The following example indicates that pat2 matches the string "abc" followed by the longest string that contains any characters from the string "12345":
Pat2 matches the string "abc123" in the text string "xyzabc123def".
Following are additional examples of statements that create complex patterns:
You can assign a pattern to a variable and then use the variable as a parameter for the SEARCH or SEARCH_QUIETLY built-in procedure. SEARCH or SEARCH_QUIETLY looks for the character sequences specified by the pattern that you use as a parameter. If SEARCH or SEARCH_QUIETLY finds a match for the pattern, the built-in returns a range that contains the text that matches the pattern. You can assign the range to a variable.
The following example uses strings and pattern operators to create a pattern that is stored in the variable my_pat. The variable is then used with the SEARCH or SEARCH_QUIETLY built-in procedure in a forward direction. If SEARCH or SEARCH_QUIETLY finds a match for my_pat, the range of matching text is stored in the variable match_range. The POSITION built-in procedure causes the editing point to move to the beginning of match_range.
3.7.1 Using Pattern Built-In Procedures and Keywords
The following built-in procedures return values of the pattern data type:
See the DEC Text Processing Utility Reference Manual for a
complete description of these pattern built-in procedures.
You can use the following keywords as the first argument to the SEARCH or SEARCH_QUIETLY built-in procedures. You can also use them to form patterns in expressions that use the pattern operators. See the DEC Text Processing Utility Reference Manual for a complete description of these keywords.
3.7.3 Using Pattern Operators
The following are the DECTPU pattern operators:
The pattern operators are equal in DECTPU's precedence of operators. For more information on the precedence of DECTPU operators, see Chapter 4. Pattern operators associate from left to right. Thus, the following two DECTPU statements are identical:
In addition to the pattern operators, you can use two relational operators, equal (=) and not equal (<>), to compare patterns.
The following sections discuss the pattern operators.
The concatenation operator (+) tells SEARCH or SEARCH_QUIETLY that text matching the right pattern element must immediately follow the text matching the left pattern element in order for the complete pattern to match. In other words, the concatenation operator specifies a search in which the right pattern element is anchored to the left. For example, the following pattern matches only if there is a line in the searched text that ends with the string abc.
If SEARCH or SEARCH_QUIETLY finds such a line, the built-in returns a range that contains the text abc and the end of the line.