M!INTOUCH® 4GL Y

INTOUCH® 4GL
A Guide to the INTOUCH Language

A
Previous page... 6Table 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  D                  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - E                 |                                                 | 6                     Cleared area is in Reverse video E                 |                                                 |  E                 |                                                 | D                  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 




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





BOX Option





:The BOX option creates an empty box with a frame. 

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





FORMAT:



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


EXAMPLE:



        10  CLEAR 0            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  E                 +-------------------------------------------------+ E                 |                                                 | E                 |         Inside the box                          | E                 |                                                 | E                 |                                                 | E                 |                                                 | E                 +-------------------------------------------------+         Outside the box 
B

6.6 OPTION COMMUNICATE ON | OFF



FSome VMS facilities can broadcast messages to your terminal. INTOUCH Dwill trap those messages and display them within the message area. BBroadcast 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?   E           .New mail on node FAST from FAST::MOLLY        (12:01:08) 


PURPOSE:





BDetermines whether to display messages broadcast to the terminal. 





DESCRIPTION:





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




@

Chapter 7
Program Directives



9

7.1 Compile Directives



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

3

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, Hon the message line. The message is displayed when a program is OLD'ed into a workspace or compiled. 



9

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:





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



3

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:





A%INCLUDE includes a source code, file_spec, file into the Icurrent 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:





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

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



1

7.1.5 %DEBUG



FORMAT:



!        %DEBUG INTOUCH_statement 


EXAMPLE:



'        10  %DEBUG PRINT 'DEBUG Items'         20  END 


DESCRIPTION:





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




A

Chapter 8
Assigning Variables



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

EThe LET statement assigns the value of an expression to a variable. DThe expression is evaluated and its value is stored in the location Aspecified by the variable. The data types of the expression and Bthe variable must match. Thus, you must assign a string variable <string values and you must assign numeric variables numeric Bvalues. A string variable must end with a dollar sign "$" unless Byou 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, Binteger or real. Once the variable has been declared, you do not Eneed 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 7            PRINT name; ' is a'; AGE; 'year old '; sex 6            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, Gfunctions, etc. Once you have declared the data type of a variable or Dfunction, 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 Bvariables or functions. INTEGER declares integer numeric. @REAL indicates real numeric. Only one of the three data Mtype 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 Htype DYNAMIC. A variable of type DYNAMIC receives the data type of the data that you put into it. 

FYou 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 5            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 8of type STRUCTURE, you can use it in statements such as ASET STRUCTURE..ID to write generalized routines where you do not ;know at compile time which structure you are going to use. 

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



9

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:





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

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

#        DECLARE PREFIX prefix_name 



EXAMPLE:



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


DESCRIPTION:





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

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

        ROUTINE routine_name         END ROUTINE         DECLARE PREFIX none 


LIn addition, at run time, prefixing is turned off before and after a string +is EXECUTEd. (See Section 11.3 for Jinformation 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 


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

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

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


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

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

L        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

8.2 OPTION Statements



A

8.2.1 OPTION REQUIRE DECLARE



FORMAT:



        OPTION REQUIRE DECLARE 


EXAMPLE:



#        10  OPTION REQUIRE DECLARE )        20  DECLARE STRING name, comment 1        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 6        Enter a comment in quotes? 'Have a nice day!' (        George says, 'Have a nice day!' 


DESCRIPTION:





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



6

8.2.2 OPTION BASE



FORMAT:



        OPTION BASE  [0 | 1] 


DESCRIPTION:





AOPTION BASE sets the lowest subscript or base for arrays. JThe base can be either zero or one. If you use OPTION BASE 0, the lowest Kelement 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$ 5            LET name$ = first$ & ' ' & last$             PRINT name$         20  END          RNH         Last name? Taylor         First name? Rick         Rick Taylor 


PURPOSE:





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



DESCRIPTION:





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

9NOTE: The keyword LET is optional. For example: 

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

-        name$ = first$ & ' ' & last$ 


KWhen INTOUCH executes the LET statement, it first evaluates the expression Hon the right side of the equal sign. It then assigns this value to the Hvariable on the left side of the equal sign. The variable represents a Mlocation in memory. The value of the expression is stored in this location. KEach 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 1        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



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

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

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


GIn the following example, the RSET statement is used to assign the new Kvalue 'Page 12' to HEADING$. INTOUCH uses the current length of HEADING$, G20 characters, and replaces it with the new value, 'Page 12'. INTOUCH Hright-justifies this value by padding it with 13 leading spaces. 8Thus, 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:





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



0

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:





MWhen INTOUCH executes the RSET statement, it evaluates the string expression Kon the right side of the equal sign. INTOUCH assigns the new value to the Lstring variable and right-justifies this value within the length of the old Jvalue. If the new value has leading or trailing spaces, these spaces are Kcarried 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:





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



<

8.5 LSET, RSET, CSET FILL



FORMAT:



9        LSET | RSET | CSET FILL str_expr: str_var = expr 


EXAMPLE:



?        10  heading$ = REPEAT$('.', 20)          ! Twenty dots %        20  PRINT '('; heading$; ')' 0        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. 



E

8.6 DATA, READ, RESTORE Statements



/

8.6.1 READ



FORMAT:



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





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



DESCRIPTION:





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

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

EWhen INTOUCH executes the first READ statement, it goes to the first GDATA statement and assigns the items in the DATA list to the variables Cin the READ list. The first variable in the READ list is assigned Cthe 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. 

7        DATA constant, constant, constant, constant...         .          0        .       |         |         |         | ,        .                                   7        READ variable, variable, variable, variable... 


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

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


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

HWhen 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) B         50  PRINT months$(1), months$(2), months$(3), months$(4)          60  END  
         RNH 4         January     February      March      April 


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

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

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

4See Section 8.6.2 for information on using RESTORE. 





4


Next page... | 6Table of Contents