M!INTOUCH® 4GL Y

INTOUCH® 4GL
A Guide to the INTOUCH Language

A
Previous page... 6Table of Contents


        COMPILE 


EXAMPLE:



        COMPILE 


PURPOSE:





>Use COMPILE to compile your finished INTOUCH programs. KCompiled 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. 

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

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

        $ INTOUCH print_name 


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



@

2.3.14.1 Compiled Images



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

BINTOUCH images are compiled from outside the INTOUCH environment. 5To 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 


H

2.3.14.2 Running Compiled Images



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

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


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

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


H

2.3.15 Developing INTOUCH Programs



4The following command entered at the system prompt: 

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

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

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

2.3.16 GO



FORMAT:



        GO 


EXAMPLE:



        GO 


DESCRIPTION:





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

LGO resumes program execution after it has been interrupted. Once execution Khas stopped, you can enter immediate mode and debug commands, change code, Hetc. GO lets you resume execution even after changing code. If a HALT Lor 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



3

2.3.17 UNSAVE



FORMAT:



        UNSAVE ['file_spec'] 


EXAMPLE:



        UNSAVE 'print_name' 


DESCRIPTION:





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




R

Chapter 3
Program Elements and Data in INTOUCH



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

?

3.1 INTOUCH Program Elements



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

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

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


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

EWith 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 Ginstructions you have given. You will need to use commands as well as %statements to develop your programs. 

JWhen 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 Hthe day in. There are several other reserved words that INTOUCH uses. AYou can refer to Appendix B, Reserved Words to see a list of the reserved words. 

AINTOUCH programs are modular in structure. Every program can be Cdivided 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. 

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


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

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


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

EMultiple statements can be placed on a single line, delimited by the 7\ (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

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



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

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

3.1.1 Continuing Program Lines



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

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

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

,

Note

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



EYou can continue statements between words; however, you cannot break up a word. 

1

3.1.2 Labels



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





ETo use a label, put the label name on a program line and separate it Gfrom the following statement with a colon. The label name can also be Kput 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$ 0            PRINT name$; ', have a good '; day$         30  END 
C

3.1.3 Storing INTOUCH Programs



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

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

6

3.2 Data in INTOUCH



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

5

3.2.1 Data Types



+INTOUCH accepts three basic types of data: 



    
  1. integer numbers 
  2. real numbers !
  3. and string (textual) data 



AThe following sections describe each of the three types of data. 

7

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% 


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

9              5.4             894.0              -369004 


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

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





:

3.2.1.3 String Data



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

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


About string data: 





2

3.2.2 BOOLEAN



;Boolean variables represent either a TRUE or FALSE) Ccondition. 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 
6

3.2.3 Expressions



Expressions can be: 





4

3.2.4 Constants



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

@

3.2.4.1 Numeric constants



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

%                235             412% 


FReal numeric constants are written with a sign, digits, and a decimal 7point. For example, 5.38 is a real numeric constant. 

9

3.2.4.2 E Notation



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

#                +/- number E +/- n 


0  # &    y    A    =    }    G  
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 


DThis means "take 1 and multiply it by 10 to the 3rd power" which is B1*(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



DString constants must be enclosed in quotes. The quotes are called >string delimiters. They tell INTOUCH where the string Ebegins and ends. The quotes are not considered part of the string. GEverything within the quotes is considered part of the string. /Note that the following strings are different: 

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


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

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

KQuotes 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!' 


DThe 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!" 
4

3.2.5 Variables



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





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





GVariables 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 


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

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

$                TODAY$           X$ )                LAST_NAME$       ANSWER$ 


KA variable that is not followed by a $ or a % is treated as a real numeric Mvariable unless it is declared. If you assign string data to a real numeric Fvariable, an error will result. If you assign integer data to a real Lnumeric 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 


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

5

3.2.5.1 Arrays



DAn array is a variable that consists of a group of elements. FEach 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) 


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

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

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


About arrays: 





9

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. beginFis the position in the string where your substring begins. endLis the position at which the substring ends. For example, here is a string called ALPHABET$: 

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


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

<begin and end are integers. If you give real Hnumbers for these positions, INTOUCH rounds them and uses the remaining Fintegers. You can manipulate a substring like any other expression. EYou 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. 


4


Next page... | 6Table of Contents