INTOUCH® 4GL
A Guide to the INTOUCH Language


Previous page... Table of Contents

        COMPILE 

EXAMPLE:

        COMPILE 

PURPOSE:

Use COMPILE to compile your finished INTOUCH programs. Compiled INTOUCH programs can be run from outside the INTOUCH environment.

DESCRIPTION:

COMPILE converts the program in current memory into an INTOUCH RUN file. This RUN file can then be executed from outside the INTOUCH environment. COMPILE only works on the program in current memory.

When INTOUCH executes the COMPILE command, it compiles the source code and saves the compiled copy with the current workspace name and the extension .RUN (i.e. PRINT_NAME.RUN). If a compiled version of the file already exists, INTOUCH compiles the new version, saves it and increments the version number by 1.

You can run compiled programs by typing INTOUCH followed by the filename at the system prompt. For example:

        $ INTOUCH print_name 

The above command starts INTOUCH and runs the compiled version of the PRINT_NAME program. When execution is complete, INTOUCH will be exited and you will return to the system prompt.

2.3.14.1 Compiled Images

INTOUCH procedures and programs can also be compiled into fast-starting memory images. These images are activated within two seconds, regardless of the size of the INTOUCH procedure or program. The drawback of using compiled images is that they are very large. The minimum size is approximately 500 disk blocks. Image sizes increase in 256 block increments.

INTOUCH images are compiled from outside the INTOUCH environment. To compile into an image, use the following command:

        $ INTOUCH/COMPILE filename 
 
    Example: 
 
        $ INTOUCH/COMPILE print_name 

Compiled image files have a file extension of .INT_IMG for VAX systems and .INT_IMG_AXP for Alpha AXP systems.

        $ INTOUCH/COMPILE CUSTOMER 
 
    will create: 
 
            CUSTOMER.INT_IMG            <--- on VAX systems 
 
            CUSTOMER.INT_IMG_AXP        <--- on AXP systems 

2.3.14.2 Running Compiled Images

You can run INTOUCH compiled images from outside of the INTOUCH environment. To run an image, use the following command format:

        $ INTOUCH/IMAGE filename 
 
    Example: 
 
        $ INTOUCH/IMAGE customer 

To set up a DCL symbol to run an INTOUCH compiled image, use the following command format:

        $ symbolname :== '$INTOUCH_IMAGE filename/IMAGE' 
 
    Example: 
 
        $ MAINTAIN :== '$INTOUCH_IMAGE TTI_RUN:MAINTAIN/IMAGE' 

2.3.15 Developing INTOUCH Programs

The following command entered at the system prompt:

        $ INTOUCH/DEVELOP filename.INT 
 
    Example: 
 
        $ INTOUCH/DEVELOP sample_print.int 
puts you into INTOUCH, OLD's in filename.INT and automatically replaces the file when you enter EXIT to exit INTOUCH.

This command streamlines the file change procedures by performing these steps for you:

        $ INTOUCH               gets into the INTOUCH environment 
 
        OLD 'filename'          brings the file into the workspace 
 
        REPLACE 'filename'      after you make your changes and enter 
                                EXIT, INTOUCH adds "1" to the version 
                                number and replaces the file 

2.3.16 GO

FORMAT:

        GO 

EXAMPLE:

        GO 

DESCRIPTION:

Use GO to continue a program after it has been interrupted.

GO resumes program execution after it has been interrupted. Once execution has stopped, you can enter immediate mode and debug commands, change code, etc. GO lets you resume execution even after changing code. If a HALT or BREAK statement was used, execution resumes at the first statement after the HALT or BREAK.


10 DEBUG ON 20 FOR i = 1 TO 6 30 IF i = 4 THEN BREAK 40 NEXT i 50 END INTOUCH RNH BREAK at 30 INTOUCH PRINT SQR(i) 2 INTOUCH 35 PRINT i; GO 4 5 6 INTOUCH

2.3.17 UNSAVE

FORMAT:

        UNSAVE ['file_spec'] 

EXAMPLE:

        UNSAVE 'print_name' 

DESCRIPTION:

UNSAVE deletes or unsaves the latest version of the file specified. The file_spec is the specification for the file. If no file_spec is given, INTOUCH uses the current workspace name and the default extension .INT. When INTOUCH executes the UNSAVE command, it searches for the file specified and then deletes that file. The source program will still remain in current memory.


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


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

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 
 
        RNH 
         4 
         4.5 
         5 
         5.5 
         6 
         6.5 
         7 

Note

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 
                ------- 
                ------- 
                ------- 
           END 

3.1.1 Continuing Program Lines

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 
 
        RNH 
        Please enter your name? Julian 
        Hello, Julian 
        Today is Tuesday 
        Julian, have a good Tuesday 

Note

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.

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.

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

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

3.2.1.3 String Data

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

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

About string data:

3.2.2 BOOLEAN

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

        10  done? = FALSE 
            DO 
              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.

3.2.4.1 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.

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

                +1E3 

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 

3.2.4.3 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 
 
        RNH 
        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.

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

                QUANTITY(1) 
                QUANTITY(2) 
                QUANTITY(3) 
                QUANTITY(4) 
                QUANTITY(5) 

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:

3.2.5.2 Substrings

Substrings are a way to refer to a part of a string. The format of a substring is:

                str_var [begin : end] 

str_var is the name of a string variable. begin is the position in the string where your substring begins. end is the position at which the substring ends. For example, here is a string called ALPHABET$:

        10  alphabet$ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 
        20  PRINT alphabet$[9:14] 
        30  END 
 
        RNH 
        IJKLMN 

The substring ALPHABET$[9:14] tells INTOUCH to begin at the ninth character and count to the 14th character. Everything between and including these two positions makes up the substring. Therefore, the substring is "IJKLMN".

begin and end are integers. If you give real numbers for these positions, INTOUCH rounds them and uses the remaining integers. You can manipulate a substring like any other expression. You can store data in the substring. And, you can use substrings to change the value of a string. For example:

        10  LET a$ = 'Your tests are in.' 
        20  PRINT a$ 
        30  LET a$[6:10] = 'results' 
        40  PRINT a$ 
        50  END 
 
        RNH 
        Your tests are in. 
        Your results are in. 


Next page... | Table of Contents