INTOUCH® 4GL
A Guide to the INTOUCH Language


Previous page... Table of Contents

        CLEAR AREA [, attr_list:] row_1, col_1, row_2, col_2 

EXAMPLE:

        10  CLEAR 
            CLEAR AREA REVERSE: 5, 10, 11, 60 
            PRINT AT 7, 20: 'Cleared area is in Reverse video' 
        20  END 
 
        RNH 
 
                  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
                 |                                                 | 
                     Cleared area is in Reverse video 
                 |                                                 | 
 
                 |                                                 | 
                  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 

CLEAR AREA allows the following attributes to be used when clearing an area: [BOLD], [BLINK], [REVERSE], [UNDERLINE]. Multiple attributes used in one statement are separated by commas.

BOX Option

The BOX option creates an empty box with a frame.

The [BOLD], [BLINK], [REVERSE] and [UNDERLINE] attributes can also be used with the BOX option. Separate attributes in one statement with commas.

FORMAT:

        CLEAR AREA BOX [, attr_list:] row_1, col_1, row_2, col_2 

EXAMPLE:

        10  CLEAR 
            CLEAR AREA BOX, BOLD: 5, 10, 11, 60 
        20  PRINT AT 7, 20: 'Inside the box' 
            PRINT AT 12, 1: 'Outside the box' 
        30  END 
 
        RNH 
 
                 +-------------------------------------------------+ 
                 |                                                 | 
                 |         Inside the box                          | 
                 |                                                 | 
                 |                                                 | 
                 |                                                 | 
                 +-------------------------------------------------+ 
        Outside the box 

6.6 OPTION COMMUNICATE ON | OFF

Some VMS facilities can broadcast messages to your terminal. INTOUCH will trap those messages and display them within the message area. Broadcast messages (communications) will stay on the screen until another message of any type is displayed.

FORMAT:

        OPTION COMMUNICATE ON | OFF 

EXAMPLE:

        10  CLEAR 
            OPTION COMMUNICATE OFF 
            PRINT AT 1,1: 
        20  INPUT 'Enter your name': name$ 
            PRINT name$ 
            OPTION COMMUNICATE ON 
        30  INPUT 'Enter your name': name$ 
            PRINT name$ 
        40  END 
 
        RNH 
 
        Enter your name? Tester 
        Tester 
        Enter your name? 
 
 
           .New mail on node FAST from FAST::MOLLY        (12:01:08) 

PURPOSE:

Determines whether to display messages broadcast to the terminal.

DESCRIPTION:

The OPTION COMMUNICATE statement turns the display of messages ON or OFF. The default is OPTION COMMUNICATE ON. If there is a message (such as a mail message), INTOUCH displays it in the message area (at the bottom of the screen). If you enter OPTION COMMUNICATE OFF, INTOUCH will not display messages.


Chapter 7
Program Directives

7.1 Compile Directives

The following sections describe the directives that are available for use in your programs. These directives are invoked when the compiler OLDs in a program and/or when a program is compiled.

7.1.1 %MESSAGE

FORMAT:

        %MESSAGE 'quoted_text' 

EXAMPLE:

        10  %MESSAGE 'Including HELP module' 
        20  %INCLUDE 'tti_run:help' 
        30  END 

DESCRIPTION:

This compiler directive displays a message, quoted_text, on the message line. The message is displayed when a program is OLD'ed into a workspace or compiled.

7.1.2 %MESSAGE ERROR

FORMAT:

        %MESSAGE ERROR: 'quoted_text' 

EXAMPLE:

        10  %MESSAGE ERROR: 'Using experimental HELP module' 
        20  %INCLUDE 'tti_run:help' 
        30  END 

DESCRIPTION:

This compiler directive rings the bell and displays an error message, quoted_text, on the message line. The message is displayed when a program is OLD'ed into a workspace or compiled.

7.1.3 %INCLUDE

FORMAT:

        %INCLUDE 'file_spec' 

EXAMPLE:

        1000  %INCLUDE 'tti_run:example' 

PURPOSE:

%INCLUDE allows you to put common subroutines into a separate file to be shared among applications.

DESCRIPTION:

%INCLUDE includes a source code, file_spec, file into the current INTOUCH program. The included file cannot contain line numbers. The default extension for the included file is .INC.

7.1.4 %INCLUDE CONDITIONAL

FORMAT:

        %include CONDITIONAL: 'file_spec' 

DESCRIPTION:

If the file to be included, file_spec, does not exist, no error is generated. This allows programs to conditionally include modules.

%INCLUDE CONDITIONAL includes a source code, file_spec, file into the current INTOUCH program if the file to be included is found. The included file cannot contain line numbers. The default extension for the included file is .INC.

7.1.5 %DEBUG

FORMAT:

        %DEBUG INTOUCH_statement 

EXAMPLE:

        10  %DEBUG PRINT 'DEBUG Items' 
        20  END 

DESCRIPTION:

The %DEBUG directive gives an error only if an image compile (/COMPILE) is being done. Use this directive to make sure that DEBUG code does not show up in production applications.


Chapter 8
Assigning Variables

Variables specify storage locations. Numeric and string variables are assigned values with the LET statement. String variables can also be assigned values with the LSET, RSET and CSET statements.

The LET statement assigns the value of an expression to a variable. The expression is evaluated and its value is stored in the location specified by the variable. The data types of the expression and the variable must match. Thus, you must assign a string variable string values and you must assign numeric variables numeric values. A string variable must end with a dollar sign "$" unless you declare it. An integer variable must end with a percent sign (%) unless you declare it.

The DECLARE statement allows you to dispense with data type designations. DECLARE declares a variable as either string, integer or real. Once the variable has been declared, you do not need to attach a $ or % to it. Functions, arrays, etc., can also be declared with the DECLARE statement.

8.1 DECLARE

FORMAT:

        DECLARE [STRING | INTEGER | REAL | DYNAMIC] var, var... 

EXAMPLE:

        10  DECLARE STRING name, sex 
            DECLARE INTEGER age 
            DECLARE REAL amount 
            DECLARE DYNAMIC anything 
        20  INPUT 'Enter your name': name 
            INPUT 'Enter your age': age 
            INPUT 'Enter your sex': sex 
            INPUT 'Enter an amount': amount 
        30  PRINT 
            PRINT name; ' is a'; AGE; 'year old '; sex 
            PRINT name; ' entered the amount'; amount 
        40  anything = 4 + 5 
            PRINT 'This dynamic variable contains: '; anything 
            anything = 'kitty' 
            PRINT 'Now it contains a string value: '; anything 
        50  END 
 
        RNH 
        Enter your name? Sammy 
        Enter your age? 28 
        Enter your sex? male 
        Enter an amount? 25.38 
 
        Sammy is a 28 year old male 
        Sammy entered the amount 25.38 
        This dynamic variable contains:  9 
        Now it contains a string value: kitty 

PURPOSE:

Use DECLARE to specify the data types of variables, functions, etc. Once you have declared the data type of a variable or function, you do not have to designate them with a trailing $ or %.

DESCRIPTION:

DECLARE declares the data type of a variable or function. The STRING option indicates that the following are string variables or functions. INTEGER declares integer numeric. REAL indicates real numeric. Only one of the three data type options can be used in each DECLARE statement. Any number of variables can be declared with a DECLARE statement.

DECLARE DYNAMIC declares one or more variables to be of type DYNAMIC. A variable of type DYNAMIC receives the data type of the data that you put into it.

You can find out the current data type of a dynamic variable with the DTYPE function. (See DTYPE(expr))

8.1.1 DECLARE STRUCTURE

FORMAT:

        DECLARE STRUCTURE struc_name1 [, struc_name2 ...] 

EXAMPLE:

        10  DECLARE STRUCTURE str 
            OPEN STRUCTURE cl: NAME 'tti_run:client' 
            ASK STRUCTURE cl: ID cl_id$ 
            SET STRUCTURE str: ID cl_id$ 
        20  EXTRACT STRUCTURE str 
            END EXTRACT 
            FOR EACH str 
              PRINT str(#1); ' '; str(#2) 
            NEXT str 
        30  END 
 
        RNH 
        20000 Smith 
        20001 Jones 
        20002 Kent 
        23422 Johnson 
        32001 Waters 
        43223 Errant 
        80542 Brock 
        80543 Cass 
        80544 Porter 
        80561 Derringer 
        80573 Farmer 

DESCRIPTION:

DECLARE STRUCTURE declares one or more symbols to be of type STRUCTURE. Once you have declared a symbol to be of type STRUCTURE, you can use it in statements such as SET STRUCTURE..ID to write generalized routines where you do not know at compile time which structure you are going to use.

Usage example: This statement could be used in the situation where you have a transaction structure and a transaction history structure and, optionally, want a report on one or the other. You could use one report program and the DECLARE STRUCTURE statement to declare which structure to use when the user makes the report selection.

8.1.2 DECLARE PREFIX

FORMAT:

        DECLARE PREFIX str_expr 

EXAMPLE:

        irp$total   prefix is IRP 
        doit$now$   prefix is DOIT 
        doing_it$   there is no prefix 

DESCRIPTION:

Any variable that contains as part of the body of its name a "$" is said to be a PREFIXED variable.

In some cases, you might want an IMPLICIT prefix for variables in a routine. To declare an IMPLICIT prefix:

        DECLARE PREFIX prefix_name 

EXAMPLE:

        PRINT total    <-->  PRINT doit$total 
        PRINT name$    <-->  PRINT doit$name$ 
        PRINT xyz$sum  <-->  PRINT xyz$sum    (prefix is explicitly given) 

DESCRIPTION:

The DECLARE PREFIX statement causes all non-prefixed variable references, structure name references and field name references to inherit a prefix (i.e. "DOIT").

Declared prefixes are local to the routine that they are declared in. For this first release, nested declared prefixes are not supported. The following statements turn OFF any declared prefixing:

        ROUTINE routine_name 
        END ROUTINE 
        DECLARE PREFIX none 

In addition, at run time, prefixing is turned off before and after a string is EXECUTEd. (See Section 11.3 for information on the EXECUTE statement.) This allows you to locally prefix executed code:

        10  a = 100 
        20  EXECUTE 'DECLARE PREFIX excode \ a = 45 \ PRINT a' 
        30  PRINT a 
        40  EXECUTE 'PRINT excode$a' 
        50  END 
 
        RNH 
        45 
        100 
        45 

If you want the same prefix to be used throughout an entire procedure, you need to put a DECLARE PREFIX at the beginning of the procedure and after every ROUTINE statement.

When referencing structure field names and using a prefix, you must:

        STRUC(#'field_name') 
 
               so: 
 
        VEND(city)  --> vend(#'city') 

Without the quotes, CITY would receive a prefix and would be an invalid field name.

Prefixing also applies to structure names. Therefore, if the structure is not opened within the prefixed routine that references it, you must have opened the structure with an explicit prefix.

        10  OPEN STRUCTURE ar$cust : NAME 'tti_run::customer', ACCESS INPUT 
            GOSUB find_customer 
            STOP 
 
       100  ROUTINE find_customer 
              DECLARE PREFIX find 
              c$ = '13727' 
              SET STRUCTURE ar$cust, FIELD custnbr : KEY c$ 
              PRINT ar$cust(#'name') 
            END ROUTINE 
       999  END 

8.2 OPTION Statements

8.2.1 OPTION REQUIRE DECLARE

FORMAT:

        OPTION REQUIRE DECLARE 

EXAMPLE:

        10  OPTION REQUIRE DECLARE 
        20  DECLARE STRING name, comment 
        30  INPUT 'Please enter your name': name 
        40  LINE INPUT 'Enter a comment in quotes': comment 
        50  PRINT name; ' says, '; comment 
        60  END 
 
        RNH 
        Please enter your name? George 
        Enter a comment in quotes? 'Have a nice day!' 
        George says, 'Have a nice day!' 

DESCRIPTION:

OPTION REQUIRE DECLARE causes INTOUCH to require all variables in the program to be declared. If the OPTION REQUIRE DECLARE statement is used and a variable is left undeclared, INTOUCH will return an error when program execution is attempted. The OPTION REQUIRE DECLARE statement should occur before any DECLARE statements and before any variables are assigned.

8.2.2 OPTION BASE

FORMAT:

        OPTION BASE  [0 | 1] 

DESCRIPTION:

OPTION BASE sets the lowest subscript or base for arrays. The base can be either zero or one. If you use OPTION BASE 0, the lowest element of an array has the subscript zero (0). If you use OPTION BASE 1, the lowest element is subscript one (1).

See Section 10.1.3 for an example and detailed information on this statement.

8.3 LET

FORMAT:

        [LET] var = expr 

EXAMPLE:

        10  INPUT 'Last name': last$ 
            INPUT 'First name': first$ 
            LET name$ = first$ & ' ' & last$ 
            PRINT name$ 
        20  END 
 
        RNH 
        Last name? Taylor 
        First name? Rick 
        Rick Taylor 

PURPOSE:

Use the LET statement to store information into a variable or data structure.

DESCRIPTION:

var is the variable being assigned a value. expr is an expression. The expression is evaluated and its result is assigned to the variable. The expression can be any INTOUCH expression (see Section 3.2.) The variable and the expression data types must match. For instance, if var is a string variable, expr must be a string expression.

NOTE: The keyword LET is optional. For example:

        LET name$ = first$ & ' ' & last$ 
can be stated as:

        name$ = first$ & ' ' & last$ 

When INTOUCH executes the LET statement, it first evaluates the expression on the right side of the equal sign. It then assigns this value to the variable on the left side of the equal sign. The variable represents a location in memory. The value of the expression is stored in this location. Each time a new value is assigned, the old value is lost and the new value is stored in its memory location.

Assigning Numeric Values

        10  INPUT 'Amount': amount 
            LET rounded% = amount 
        20  PRINT 'Real numeric amount:'; amount 
            PRINT 'Integer amount (after rounding):'; rounded% 
        30  END 
 
        RNH 
        Amount? 1.54 
        Real numeric amount: 1.54 
        Integer amount (after rounding): 2 

Assigning String Values

8.4 LSET, RSET and CSET

LSET, RSET and CSET assign string values to variables. LSET left-justifies the new value. RSET right-justifies and CSET center-justifies it. These statements can only be used to assign string values.

LSET, RSET and CSET justify the new value within the length of the previous value. For example, in the following program, HEADING$ has a length of twenty characters and consists of twenty dots:

        10  heading$ = REPEAT$('.', 20)          ! Twenty dots 
        20  PRINT '('; heading$; ')' 
        30  END 
 
        RNH 
        (....................) 

In the following example, the RSET statement is used to assign the new value 'Page 12' to HEADING$. INTOUCH uses the current length of HEADING$, 20 characters, and replaces it with the new value, 'Page 12'. INTOUCH right-justifies this value by padding it with 13 leading spaces. Thus, HEADING$ still has a length of twenty characters.

        10  heading$ = REPEAT$('.', 20)          ! Twenty dots 
            PRINT '('; heading$; ')' 
        20  RSET heading$ = 'Page 12' 
            PRINT '('; heading$; ')' 
        30  END 
 
        RNH 
        (....................) 
        (             Page 12) 

8.4.1 LSET

FORMAT:

        LSET str_var = str_expr 

EXAMPLE:

        10  heading$ = REPEAT$('.', 20)          ! Twenty dots 
        20  PRINT '('; heading$; ')' 
        30  LSET heading$ = 'Page 12' 
            PRINT '('; heading$; ')' 
        40  END 
 
        RNH 
        (....................) 
        (Page 12             ) 

PURPOSE:

Use LSET to left-justify string data.

DESCRIPTION:

When INTOUCH executes an LSET statement, it evaluates the string expression on the right side of the equal sign. INTOUCH assigns the new value to the string variable and left-justifies this value within the length of the old value. If the new value has leading or trailing spaces, these spaces are carried over and the string is justified with those spaces. LSET can only be used with strings.

8.4.2 RSET

FORMAT:

        RSET str_var = str_expr 

EXAMPLE:

        10  heading$ = REPEAT$('.', 20)          ! Twenty dots 
        20  PRINT '('; heading$ ;')' 
        30  RSET heading$ = 'Page 12' 
            PRINT '(' ; heading$ ; ')' 
        40  END 
 
        RNH 
        (....................) 
        (             Page 12) 

PURPOSE:

Use RSET to right-justify string data.

DESCRIPTION:

When INTOUCH executes the RSET statement, it evaluates the string expression on the right side of the equal sign. INTOUCH assigns the new value to the string variable and right-justifies this value within the length of the old value. If the new value has leading or trailing spaces, these spaces are carried over and the string is justified with those spaces. RSET can only be used with strings.

8.4.3 CSET

FORMAT:

        CSET str_var = str_expr 

EXAMPLE:

        10  heading$ = REPEAT$('.', 20)          ! Twenty dots 
        20  PRINT '('; heading$; ')' 
        30  CSET heading$ = 'Page 12' 
            PRINT '('; heading$; ')' 
        40  END 
 
        RNH 
        (....................) 
        (       Page 12      ) 

PURPOSE:

Use CSET to center string data.

DESCRIPTION:

When INTOUCH executes the CSET statement, it evaluates the expression on the right side of the equal sign. Next, INTOUCH assigns the new value to the string variable and centers it within the length of the old value. If the string value has leading or trailing spaces, the spaces are carried over and the string is centered with those spaces. CSET can only be used with strings.

8.5 LSET, RSET, CSET FILL

FORMAT:

        LSET | RSET | CSET FILL str_expr: str_var = expr 

EXAMPLE:

        10  heading$ = REPEAT$('.', 20)          ! Twenty dots 
        20  PRINT '('; heading$; ')' 
        30  CSET FILL '*': heading$ = 'Page 12' 
            PRINT '('; heading$; ')' 
        40  END 
 
        RNH 
        (....................) 
        (*******Page 12******) 

DESCRIPTION:

The value of expr is left-justified, right-justified or centered inside the str_var. The remaining part of the string is filled with the pattern specified by str_expr. If str_expr is the null string, no filling occurs---the remaining part of the string is left as is.

8.6 DATA, READ, RESTORE Statements

8.6.1 READ

FORMAT:

        DATA [num_const | str_const] [,[num_const | str_const]...] 
                      . 
                      . 
                      . 
        READ [num_var | str_var] [,[num_var | str_var]...] 

EXAMPLE:

        10  DIM months$(6) 
        20  DATA January, February, March 
        30  DATA April, May, June 
        40  FOR i = 1 TO 6 
              READ months$(i) 
              PRINT months$(i) 
            NEXT i 
        50  END 
 
        RNH 
        January 
        February 
        March 
        April 
        May 
        June 

PURPOSE:

Use DATA and READ statements to assign data to variables in cases where the data will not change with successive runs of the program.

DESCRIPTION:

The READ and DATA statements assign data to variables. DATA specifies a list of data to assign. The data must be given as constants and can be string, numeric or integer types. Multiple data items must be separated by commas.

The READ statement specifies a list of variables to assign data to. The variables can be string, numeric or integer variables. They can be substrings, array elements, etc..

When INTOUCH executes the first READ statement, it goes to the first DATA statement and assigns the items in the DATA list to the variables in the READ list. The first variable in the READ list is assigned the first value in the DATA list. The second variable in the READ list is assigned the second value in the DATA list, and so on.

        DATA constant, constant, constant, constant... 
        .          
        .       |         |         |         | 
        .                                   
        READ variable, variable, variable, variable... 

If the data item contains a commas, the data item should be enclosed with single or double quotes. For example:

        10  DIM amounts$(3) 
        20  DATA '$25,000', '$250,000', '$2,500,000' 
        30  READ amounts$(1), amounts$(2), amounts$(3) 
        40  PRINT amounts$(1), amounts$(2), amounts$(3) 
        50  END 
 
        RNH 
        $25,000             $250,000            $2,500,000 

The variable types and data types must match or an exception will result. For example, if the third item in the DATA list is a string constant, and the third variable in the READ list is a numeric variable, an exception will result.

When the second READ statement is executed, INTOUCH starts reading from the first unread data item in the DATA list. For example:

         10  DIM months$(4) 
         20  DATA January, February, March, April, May, June 
         30  READ months$(1), months$(2) 
         40  READ months$(3), months$(4) 
         50  PRINT months$(1), months$(2), months$(3), months$(4) 
         60  END 
 
         RNH 
         January     February      March      April 

In the example above, when the first READ statement is executed, INTOUCH reads the months January and February. When the second READ statement is executed, INTOUCH will continue at the first unread month--March--and read it into months$(3).

If you attempt to read more data than exists, that is, if your READ list has more items than than your DATA list, an exception will result. You can avoid this by using the RESTORE statement to restore the DATA list and read from the beginning again.

The READ and DATA statements must occur in the same program unit. For example, you cannot not have your DATA statements in the main program unit and your matching READ statements in a subprogram.

See Section 8.6.2 for information on using RESTORE.


Next page... | Table of Contents