A Guide to the INTOUCH Language

Previous Contents Index

Chapter 3
Program Elements and Data in INTOUCH

This chapter describes the basic elements that make up an INTOUCH program. It also describes the types of data used with INTOUCH programs and how the data is processed.

3.1 INTOUCH Program Elements

A program is a series of instructions. These instructions describe how to manipulate data to produce a desired result. You determine what data the program will manipulate, how the program will manipulate it and what the results of these manipulations will be.

When you create a program, you must use instructions that INTOUCH understands. The INTOUCH language provides these instructions. The language consists of statements. These statements are something like the words in this manual. You put them together in a meaningful order and INTOUCH executes the program you write. Here is an example of an INTOUCH program:

        10  INPUT 'Please enter your name': name$ 
        20  PRINT 'Hello, '; name$ 
            PRINT 'Today is '; day$ 
            PRINT name$; ', have a good '; day$ 
        30  END 

The INPUT statement tells INTOUCH to ask for a name. The PRINT statements tell INTOUCH to print the information. END tells INTOUCH it has reached the end of the program.

With INTOUCH, when you execute this program, it will look like this:

Example 3-1 Executing an INTOUCH program

10  INPUT 'Please enter your name': name$ 
20  PRINT 'Hello, '; name$ 
    PRINT 'Today is '; day$ 
    PRINT name$; ', have a good '; day$ 
30  END 
NONAME         2-MAY-1996 10:45 
Please enter your name? Julian 
Hello, Julian 
Today is Tuesday 
Julian, have a good Tuesday 

RUN is a command. RUN tells INTOUCH to perform the instructions you have given. You will need to use commands as well as statements to develop your programs.

When you run the above program, you will notice that the day is not asked for. DAY$ is a reserved word that INTOUCH uses to store the day in. There are several other reserved words that INTOUCH uses. You can refer to Appendix B, Reserved Words to see a list of the reserved words.

INTOUCH programs are modular in structure. Every program can be divided into program units. The main unit is the main body of the program. This unit begins with the first program line and ends with the END statement.

    First program line --   10  INPUT 'Please enter your name': name$ 
                            20  PRINT 'Hello, '; name$ 
                                PRINT 'Today is '; day$ 
                                PRINT name$; ', have a good '; day$ 
         END statement --   30  END 

Each program unit is made up of program lines. A program line consists of one or more statements. In the above example, line 20 has three statements. If you include more than one statement in a line, you must separate the statements with a line terminator (a carriage return). You can terminate a line from the keyboard by pressing the [Return] or [Enter] key. For example:

        10  INPUT 'Please enter your name': name$<Return> 
        20  PRINT 'Hello, '; name$<Return> 
            PRINT 'Today is '; day$<Enter> 
            PRINT name$; ', have a good '; day$<Return> 
        30  END<Return> 

When INTOUCH executes a program, it starts at the lowest line number and executes all the statements in that program line. Then it goes to the next sequential line number and executes all the statements in that line and so on.

Multiple statements can be placed on a single line, delimited by the \ (backslash). CHR$(10) also signals the same as a \. A \ terminating the line implies an "&".

        10  FOR z1 = 4. to 7. STEP .5 \ PRINT z1 \ NEXT z1 
        20  END 


Putting multiple statements on a single line is not recommended. It makes changing code difficult and the logic flow is not easy to follow.

INTOUCH accepts line numbers in the range of 1 to 999999. Line numbers must be integers.

INTOUCH allows programs with NO line numbers execpt, there must be a line 1 at the beginning of the program. For example:

        1  PROGRAM print_name 

3.1.1 Continuing Program Lines and Implied Continuation

You can continue a statement on the next physical line by using an ampersand (&). This allows you to continue a statement that is too long to fit on one line.

To continue a statement, place the ampersand at the end of the continued line. You can also place an optional ampersand at the beginning of the next line. For example:

        10  INPUT 'Please enter your name': name$ 
        20  PRINT 'Hello, '; name$ 
            PRINT 'Today is '; day$ 
            PRINT name$; & 
                  ', have a good '; &      ! required ampersand 
                  & day$                   ! optional ampersand 
        30  END 
        Please enter your name? Julian 
        Hello, Julian 
        Today is Tuesday 
        Julian, have a good Tuesday 


In the above example, the comment text follows the line continuation character (&). Whenever you comment a continued line, the exclamation mark must come AFTER the ampersand.

You can continue statements between words; however, you cannot break up a word. Implied Continuation

Prior to V4.3, an ampersand (&) was required to identify a statement that was continued on the next physical line. Now the ampersand is acceptable, but no longer required in some cases. Implied continuation has been implemented for:

NOTE: Comma-separated list continuation does not work in a PRINT statement. PRINT statements still require the trailing "&" for continuation.

Here are some examples:

        10  OPEN STRUCTURE cust: NAME 'tti_run:customer',    ! no ampersand 
              ACCESS OUTIN,                                  ! no ampersand 
        20  CLOSE STRUCTURE cust 
        30  END 
        10  PRINT 'Today is the first day of the ' +         ! no ampersand 
            'rest of your life.' 
        20  a$ = 'walk' 
            b$ = 'walk' 
            c$ = 'walk' 
        30  IF  a$ = b$  AND                                 ! no ampersand 
              a$ = c$  THEN 
              PRINT 'All are the same.' 
            END IF 
        40  END 
        Today is the first day of the rest of your life. 
        All are the same. 

3.1.2 Labels

A label is a way to identify a place in a program. Labels must:

To use a label, put the label name on a program line and separate it from the following statement with a colon. The label name can also be put on a line by itself and followed by multiple statements. Both options are shown in the example below.

        10  ask_input:  INPUT 'Please enter your name': name$ 
        20  do_print: 
            PRINT 'Hello, '; name$ 
            PRINT 'Today is '; day$ 
            PRINT name$; ', have a good '; day$ 
        30  END 

3.1.3 Storing INTOUCH Programs

INTOUCH programs have a default extension of .INT so, you do not have to use a file extension with your file name when using the INTOUCH commands (SAVE, UNSAVE, OLD, etc.). It is recommended that you use this extension for all of your INTOUCH programs.

INTOUCH source programs are saved as text files. You can print the text files with the TYPE and PRINT commands, and edit them with any text editor.

3.2 Data in INTOUCH

Programs manipulate data. The data can be numeric or textual, but the data must be presented according to the rules of the INTOUCH language.

3.2.1 Data Types

INTOUCH accepts three basic types of data:
  1. integer numbers
  2. real numbers
  3. and string (textual) data

The following sections describe each of the three types of data. Integers

An integer number is a whole number with no fractional part. The following are examples of integers:

                +5%       894%       -369004% 

Integers can be positive or negative. Integer constants can end with a trailing percent sign (%). About integers: Real Numbers

A real number can have a fractional part. The following are real constants:

              5.4             894.0              -369004 

Real numbers can be positive or negative. Any number that is not designated as an integer or a string is treated as a real number.

A real number without a decimal point is called an ambiguous constant. About real numbers: String Data

String data consists of text. Text can be any characters. All of the following are valid string constants:

                 'Hello, Fred.' 
                 'Account number (##-####)' 

About string data:


Boolean variables represent either a TRUE or FALSE condition. These variables can be expressed with a trailing "?". For example:

        10  done? = FALSE 
              INPUT 'Ready': ans$ 
              IF  _EXIT  THEN  done? = TRUE 
              IF  _BACK  THEN  done? = TRUE 
            LOOP UNTIL done? 
        20  END 

3.2.3 Expressions

Expressions can be:

3.2.4 Constants

A constant is a value that does not change during a program execution. Constants can be any of the three data types: integer numeric, real numeric or string. Numeric constants

Integer numeric constants are written with digits, with no decimal fraction. An integer constant can end with a percent sign. Examples:

                235             412% 

Real numeric constants are written with a sign, digits, and a decimal point. For example, 5.38 is a real numeric constant. E Notation

E notation is a shorthand way of representing very large or very small numbers. Real numeric constants can be written in E notation. INTOUCH displays any real value of greater than 12 decimal digits in E notation. The format of E notation is:

                +/- number E +/- n 

Table 3-1 E Notation
Notation Description
+/- is the sign of the number (positive or negative). If no sign is given, the number is assumed to be positive.
number is the number on which exponentiation is performed.
E exponentiation means "times 10 to the power of".
+/- is the sign of the exponent (positive or negative). If no sign is given, the exponent is assumed to be positive.
n is the exponent represented as one or more integer digits.

If you wanted to represent 1000 in E notation, you would use:


This means "take 1 and multiply it by 10 to the 3rd power" which is 1*(10^3) = 1000. If you wanted to represent .01, you would use a negative exponent.

                1E-2 = 1*(10^-2) = .01 String Constants

String constants must be enclosed in quotes. The quotes are called string delimiters. They tell INTOUCH where the string begins and ends. The quotes are not considered part of the string. Everything within the quotes is considered part of the string. Note that the following strings are different:

        10  PRINT 'Account number (##-####)' 
        20  PRINT '    Account number     (##-####)' 
        30  END 
        Account number (##-####) 
            Account number     (##-####) 

An empty string is called a null string. A null string is indicated by a pair of quotes with nothing between them ("").

String delimiters can be single quotes (') or double quotes ("). However, the quotes must match and be paired.

Quotes can be included as part of a string by using them within the string delimiters. For example:

        "Message 'Time to go home!'" 

The string part of this is:

         Message 'Time to go home!' 

The delimiter quotes can be used within a string, by repeating them twice. For instance:

        "Message ""Time to go home!""" 

The string part of this is

         Message "Time to go home!" 

3.2.5 Variables

Variables are a way of storing values that can change in the program during execution. A variable names a storage location. The value of the variable is stored in this location. Here are two types of variables:

Two other constructs are used in ways similar to variables---you can use them in expressions and assign values to them:

Variables are represented by a name consisting of a letter or a series of letters, numbers and underscore characters. Variables:

Some examples of valid variables are:

                TODAY$           X% 
                Z                INDEX 

Variables can be integer numeric, real numeric or string. Integer variables can only contain integer values. If a real numeric value is assigned to an integer variable, INTOUCH rounds the real number and uses the resulting integer.

String variable names can have a trailing dollar sign ($). If numeric data is assigned to a string variable, an exception occurs.

                TODAY$           X$ 
                LAST_NAME$       ANSWER$ 

A variable that is not followed by a $ or a % is treated as a real numeric variable unless it is declared. If you assign string data to a real numeric variable, an error will result. If you assign integer data to a real numeric variable, INTOUCH treats it as a real number with a fractional part of 0. The following are examples of real numeric variables:

                INDEX                Z 
                COUNTER              AMOUNT 

INTOUCH uses the last assigned value when a variable is referenced.

Private Variables

See Section 11.13.3, Private Variables in Routines, for more information on using variables. Arrays

An array is a variable that consists of a group of elements. Each element represents a storage location. A different value can be assigned to each element. Here is an example of an array:


To indicate which element you want to access, you use numbers after the array name called subscripts. The subscripts are enclosed in parentheses. Example: AMOUNT(3,2)

Subscripts must be given as integers. If a real numeric subscript is given, it will be rounded and the integer portion used. Arrays can contain real numeric, integer or string values. String and integer arrays are designated by placing the appropriate symbols after the array name and before the subscript. For example:

                A$(5,10)        A%(5,10) 

About arrays:

Previous Next Contents Index