• No results found

Video Attributes: Points to Note

In document datastage basic (Page 139-146)

Terminals whose video attributes are described as embedded or on-screen use a character position on the terminal screen whenever a start or stop video attribute

@ function

is received. Programs driving such terminals must not change an attribute in the middle of a contiguous piece of text. You must leave at least one blank character position at the point where the attribute changes. The field in the terminal defini-tion record called xmc is used to specify the number of character posidefini-tions required for video attributes. A program can examine this field, and take appropriate action. To do this, the program must execute GET.TERM.TYPE and examine the @SYSTEM-.RETURN.CODE variable, or use the definition VIDEO.SPACES from the TERM INFO.H file.

Many terminals do not clear video attributes automatically when the data on a line is cleared or deleted. The recommended programming practice is to reposition to the point at which a start attribute was emitted, and overwrite it with an end attribute, before clearing the line.

On some terminals you can set up the Clear to End of Line sequence to clear both data and video attributes. This is done by combining the strings for erase data from active position to end of line, selecting Graphic Rendition normal, and changing all video attributes from active position to end of line. Sending the result of the

@(IT$CLEOL) function causes both the visible data on the line to be cleared, and all video attributes to be set to normal, after the cursor position.

Note: Where possible, you should try to ensure that any sequences that clear data also clear video attributes. This may not be the case for all terminal types.

An exception is @(IT$CS) clear screen. The sequence associated with this function should always clear not only all data on the screen but also reset any video attributes to normal.

Examples

The following example displays “Demonstration” at column 5, line 20:

PRINT @(5,20):"Demonstration"

In the next example, the PRINT statement positions the cursor to home, at the top-left corner of the screen, and clears the screen:

PRINT @(IT$CS):

The $INCLUDE statement is used to include the ATFUNCTIONS insert file of equate names. Assignment statements are used to assign the evaluated @ functions to variables. The variables are used in PRINT statements to produce code that clears the screen and returns the cursor to its original position; positions the cursor

@ function

at column 5, line 20; turns on the reverse video mode; prints the string; and turns off the reverse video mode.

$INCLUDE UNIVERSE.INCLUDE ATFUNCTIONS.H

PRINT REVERSE.ON:"THIS IS REVERSE VIDEO":REVERSE.OFF The next example displays any following text in yellow letters:

PRINT @(IT$FCOLOR, IT$YELLOW)

The next example displays any following text on a cyan background:

PRINT @(IT$BCOLOR, IT$CYAN)

The next example gives a yellow foreground, not a green foreground, because color changes are not additive:

PRINT @(IT$FCOLOR, IT$BLUE):@(IT$FCOLOR, IT$YELLOW)

If you have a terminal that supports colored letters on a colored background, the next example displays the text “Hello” in yellow on a cyan background. All subse-quent output is in yellow on cyan until another color @ function is used. If your color terminal cannot display colored foreground on colored background, only the last color command is used, so that this example displays the text “Hello” in yellow on a black background.

PRINT @(IT$BCOLOR,IT$CYAN):@(IT$FCOLOR,IT$YELLOW):"Hello"

If your color terminal cannot display colored foreground on colored background, the previous example displays the text “Hello” in black on a cyan background.

The next example gives the same result as the previous example for a terminal that supports colored letters on a colored background. Strings containing the @ func-tions can be interpreted as a sequence of instrucfunc-tions, which can be stored for subsequent frequent reexecution.

PRINT @(IT$FCOLOR,IT$YELLOW):@(IT$BCOLOR,IT$CYAN):"Hello"

In the last example, the screen is cleared, the cursor is positioned to the tenth column in the tenth line, and the text “Hello” is displayed in foreground color

@ function

cyan. The foreground color is then changed to white for subsequent output. This sequence of display instructions can be executed again, whenever it is required, by a further PRINT SCREEN statement.

SCREEN = @(IT$CS):@(10,10):@(IT$FCOLOR,IT$CYAN):"Hello"

SCREEN = SCREEN:@(IT$FCOLOR,IT$WHITE) PRINT SCREEN

[ ] operator

Syntax

expression

[ [

start,

]

length

]

expression

[

delimiter, occurrence, fields

]

Description

Use the [ ] operator (square brackets) to extract a substring from a character string.

The bold brackets are part of the syntax and must be typed.

expression evaluates to any character string.

start is an expression that evaluates to the starting character position of the substring. If start is 0 or a negative number, the starting position is assumed to be 1. If you omit start, the starting position is calculated according to the following formula:

string.length – substring.length + 1

This lets you specify a substring consisting of the last n characters of a string without having to calculate the string length.

If start exceeds the number of characters in expression, an empty string results. An empty string also results if length is 0 or a negative number. If the sum of start and length exceeds the number of characters in the string, the substring ends with the last character of the string.

length is an expression that evaluates to the length of the substring.

Use the second syntax to return a substring located between the specified number of occurrences of the specified delimiter. This syntax performs the same function as the FIELD function.

delimiter can be any string, including field mark, value mark, and subvalue mark characters. It delimits the start and end of the substring (all that appears within the two delimiters). If delimiter consists of more than one character, only the first char-acter is used.

occurrence specifies which occurrence of the delimiter is to be used as a terminator.

If occurrence is less than 1, 1 is assumed.

fields specifies the number of successive fields after the delimiter specified by occur-rence that are to be returned with the substring. If the value of fields is less than 1, 1 is assumed. The delimiter is part of the returned value in the successive fields.

[ ] operator

If the delimiter or the occurrence specified does not exist within the string, an empty string is returned. If occurrence specifies 1 and no delimiter is found, the entire string is returned.

If expression is the null value, any substring extracted from it will also be the null value.

Examples

In the following example (using the second syntax) the fourth # is the terminator of the substring to be extracted, and one field is extracted:

A="###DHHH#KK"

PRINT A["#",4,1]

This is the result:

DHHH

The following syntaxes specify substrings that start at character position 1:

expression

[

0, length

]

expression

[

–1, length

]

The following example specifies a substring of the last five characters:

"1234567890" [5]

This is the result:

67890

All substring syntaxes can be used in conjunction with the assignment operator ( = ). The new value assigned to the variable replaces the substring specified by the [ ] operator. For example:

A=’12345’

A[3]=1212 PRINT "A=",A returns the following:

A= 121212

A[3] replaces the last three characters of A (345) with the newly assigned value for that substring (1212).

[ ] operator

The FIELDSTORE function provides the same functionality as assigning the three-argument syntax of the [ ] operator.

In document datastage basic (Page 139-146)

Related documents