M!INTOUCH® 4GL Y

INTOUCH® 4GL
A Guide to the INTOUCH Language

A
Previous page... 6Table of Contents
4

4.2.5 RANDOMIZE



FORMAT:



        RANDOMIZE 


EXAMPLE:



        10  RANDOMIZE         20  x = RND             PRINT x         30  END          RNH          .244013674718          INTOUCH          RNH          .524856061388 


PURPOSE:





?RANDOMIZE gives the RND function a new starting point. GThis ensures that you will get a different random number sequence each time your program executes. 



DESCRIPTION:





IINTOUCH uses a list of random numbers when the RND function is used. If Ino RANDOMIZE statement is used, INTOUCH starts at the same place in this Klist each time the program executes. This means the same series of random 4numbers is returned each time the program executes. 

KRANDOMIZE tells INTOUCH to pick a random starting point in the list. This Hensures that a different series of random numbers is returned each time 0the program executes. (See RND for information on the RND function.) 



7

4.3 Debug Facilities



KINTOUCH detects and announces run-time and compile-time errors. Sometimes Kerrors occur which don't prevent execution, but cause a program to execute Gincorrectly. INTOUCH provides a high-level DEBUG system for detecting these more subtle errors. 

JDEBUG ON enables INTOUCH's Debug System. DEBUG OFF disables the system. IWhen DEBUG is enabled, a DEBUG flag will appear at the status message in Kthe upper right corner of the INTOUCH screen. When DEBUG is disabled, the Mflag disappears from the screen. DEBUG ON turns on the frame if it was off. 

>The related function for the INTOUCH Debug System is _DEBUG. )See _DEBUG for information on the _DEBUG system function. 

GSome DEBUG features automatically switch DEBUG ON or OFF when they are Bexecuted. Others require that DEBUG be enabled. (See DEBUG ON.) 




,

Note

IUsing the debugging facilities impacts the INTOUCH system's performance. LThe system has been designed for optimal performance in a normal production @environment. Therefore, DEBUG will slow INTOUCH response time. 



3

4.4 DEBUG ON/OFF



3

4.4.1 DEBUG ON



FORMAT:



        DEBUG ON 


EXAMPLE:



        DEBUG ON         1050 DEBUG ON 


PURPOSE:





AUse DEBUG ON to enable INTOUCH's debug system. The DEBUG Gsystem helps you find problems in the way your program runs. You must 0enable the system in order to use its features. 





DESCRIPTION:





FWhen DEBUG is enabled, all of INTOUCH's DEBUG features are available. IDEBUG remains enabled until a DEBUG OFF command or statement is executed 8or until a DEBUG feature is executed which disables it. 

IDEBUG ON can be issued in immediate mode or as a statement in a program. KIf DEBUG ON is used in a program, INTOUCH enables DEBUG when it encounters Jthe DEBUG ON statement. After you turn DEBUG ON, you must use RUN or RNH <to start the program before you can use the STEP statement. 



4

4.4.2 DEBUG OFF



FORMAT:



        DEBUG OFF 


EXAMPLE:



        DEBUG OFF         1050 DEBUG OFF 


PURPOSE:





=Use DEBUG OFF to disable INTOUCH's DEBUG system. You Fshould turn DEBUG OFF when you have finished correcting your program. 



DESCRIPTION:





JDEBUG OFF can be issued in immediate mode or as a statement in a program. BIf DEBUG OFF is used in a program, INTOUCH disables DEBUG when it $encounters the DEBUG OFF statement. 

FDEBUG will remain disabled until a DEBUG ON statement is executed, or 4until a DEBUG feature is executed which enables it. 



C

4.5 Monitoring Program Execution



IDEBUG's TRACE and STATISTICS features monitor your program's execution. :These features take effect only during program execution. 

HTRACE traces your program line by line as it executes. TRACE lists the Cnumber of each program line as it is executed. STATISTICS records Kinformation on your program's execution. It records the time each program Jline takes to execute and the number of times the line is executed. The Fword "STATISTICS" can be abbreviated to "STATS" (STATS ON, STATS OFF, GLIST STATS). This abbreviation will be used frequently in this Guide. 

H

4.6 The TRACE and STATISTICS Features



ABoth the TRACE and STATISTICS features operate on program lines. >A number of program lines can be attached to one line number. 

        10  PRINT a$             PRINT b$             PRINT c$ 


KThe TRACE feature notes these program lines by line number. For instance: 

        10  PRINT a$ --- 10 


HIf more than one program line is attached to a line number, the program >lines are denoted by a period and the number of the sub-line. 

        10  PRINT a$ --- 10             PRINT b$ --- 10.1             PRINT c$ --- 10.2 


GIn the example above, the first line is noted as 10. The program line Efollowing the first line is 10.1. The next line is 10.2 and so on. 0Labels are noted in the same way. For example: 

$        10  show: PRINT a$ --- SHOW &            PRINT b$       --- SHOW.1 &            PRINT c$       --- SHOW.2 
3

4.6.1 TRACE ON



FORMAT:



        TRACE ON 


EXAMPLE:



        TRACE ON         1050 TRACE ON 


PURPOSE:





=Use TRACE ON to turn INTOUCH's trace feature on. The Gtrace feature lists the number of each program line as it is executed. FUse TRACE to see if your statements are being executed in the correct 'order and the correct number of times. 



DESCRIPTION:





*To use TRACE, you must have the frame on. 

HTRACE ON enables INTOUCH's trace feature. The trace feature lists each Jprogram line as it is executed. TRACE ON can be executed as a command or Nas a statement. If TRACE ON is executed as a command, DEBUG is automatically Hswitched on. If TRACE ON is executed as a statement, and DEBUG is off, JINTOUCH ignores the TRACE ON. The following program is executed with the trace feature on: 

        10  DIM name$(5) !            MAIN: FOR i = 1 TO 5 =                    INPUT 'Please enter your name': name$(i) .                    IF  _EXIT  THEN  EXIT FOR 3                    PRINT 'Hello, '; name$(i); '!'                   NEXT i         20  END 

#Example 4-1 Debug TRACE ON Example


WINTOUCH 4.2 Program: NONAME DEBUG WThe Next Generation Language Status : RUN    INTOUCH TRACE ON  INTOUCH RNH Please enter your name? John Hello, John! Please enter your name? W [10] [MAIN] [MAIN.1] [MAIN.2] [MAIN.3] [MAIN.4] [MAIN.1]W WEXIT = Exit \ = Back HELP = Help





FThe trace remains in effect until a TRACE OFF command or statement is Fexecuted. When program execution stops, the trace stops. If program Eexecution continues and the TRACE ON command is still in effect, the trace continues. 



4

4.6.2 TRACE OFF



FORMAT:



        TRACE OFF 


EXAMPLE:



        TRACE OFF         1050 TRACE OFF 


PURPOSE:





4Use TRACE OFF to turn the trace feature off. 



DESCRIPTION:





ETRACE OFF disables the trace feature. INTOUCH stops listing program Hline numbers when TRACE OFF is executed. If TRACE OFF is executed as a Hstatement in a program and DEBUG is off, INTOUCH ignores the statement. 



3

4.6.3 STATS ON



FORMAT:



        STATS ON 


EXAMPLE:



        STATS ON         1020 STATS ON 


PURPOSE:





=Use STATS ON to turn on the statistics feature, which Istores the execution time and count for each program line. Use STATS to Gtell if your statements are being executed the correct number of times Dand which parts of your program are taking the most time. STATS is Aespecially useful for speeding up your program's execution time. 



DESCRIPTION:





ISTATS ON enables INTOUCH's statistics feature. INTOUCH begins recording Jstatistics when program execution begins. The statistics feature remains 3enabled until the STATS OFF statement is executed. 

ISTATS ON can be executed in immediate mode or in a program. If STATS ON Gis executed in immediate mode, DEBUG is automatically switched on. If ISTATS ON is executed in a program, and DEBUG is off, INTOUCH ignores the Jstatement. When STATS ON is executed, any statistics previously recorded are lost. 



4

4.6.4 STATS OFF



FORMAT:



        STATS OFF 


EXAMPLE:



        STATS OFF         1020 STATS OFF 


PURPOSE:





9Use STATS OFF to turn off the statistics feature. 



DESCRIPTION:





DSTATS OFF turns off INTOUCH's statistics feature. STATS OFF can be Fexecuted in immediate mode or in a program. If STATS OFF is executed ?in a program and DEBUG is off, INTOUCH ignores the statement. STATS OFF leaves DEBUG on. 



5

4.6.5 LIST STATS



FORMAT:



C        LIST STATS [:label | line_num [- | ,] label | line_num...] 


EXAMPLE:



        LIST STATS 


PURPOSE:





<Use LIST STATS to display the statistics recorded by the STATISTICS feature. 



DESCRIPTION:





KLIST STATS lists each program line along with the number of times the line 2was executed and the execution time of each line. 

/Example 4-2 Listing Statistics in DEBUG System


WINTOUCH 4.2 Program: NONAME STATS DEBUG WThe Next Generation Language Status : RUN  INTOUCH LIST STATS NONAME 4-MAY-1995 00:54 - 1 0.00 10 DIM name$(5) 5 1 0.00 MAIN: FOR i = 1 TO 5 Q 5 16.64 INPUT 'Please enter your name': name$(i) B 5 0.00 IF _EXIT THEN EXIT FOR G 5 0.00 PRINT 'Hello, '; name$(i); '!' - 5 0.00 NEXT i $ 1 0.00 20 END  INTOUCH  W WEXIT = Exit \ = Back HELP = Help





KThe far-left column lists the number of times each statement was executed. IThe next column gives the time each statement took to execute. The time His given in seconds and fractions of a second. (0.01 means the program Lline was executed in one-one hundredth of a second.) The last column lists Ethe program itself. STATS must be ON for LIST STATS to be executed. 

GAll the options available with the "LIST" statement are also available 7with LIST STATS. (See Section 2.3.7, LIST for listing information.) 



5

4.7 BREAK and STEP



0

4.7.1 BREAK



FORMAT:



        BREAK 


EXAMPLE:



        1050 BREAK 




=Use BREAK to stop program execution when DEBUG is ON. GFor instance, you might use BREAK to stop the program if a variable is assigned a wrong value. 



DESCRIPTION:





LThe BREAK statement can be used anywhere in a program. The BREAK statement Jwill not take effect unless DEBUG is turned on. If DEBUG is off, INTOUCH ignores any BREAK statements. 

IWhen INTOUCH executes a BREAK statement, it interrupts program execution Iand prints a BREAK message. The BREAK message tells what line the break Eoccurred in. Program execution can be continued with the GO or STEP commands. 

(Example 4-3 Using BREAK in DEBUG System


WINTOUCH 4.2 Program: NONAME DEBUG WThe Next Generation Language Status : BREAK at 10.2 10 PRINT '1',  PRINT '2', BREAK  PRINT '3',  PRINT '4',  PRINT '5' 20 END DEBUG ON  INTOUCH RNH 61 2 BREAK at 10.2  INTOUCH W WEXIT = Exit \ = Back HELP = Help

/

4.7.2 STEP



FORMAT:



        STEP [number] 


EXAMPLE:



        STEP         STEP 10 


PURPOSE:





CUse STEP to execute a specific number of program statements Land then stop execution. That way, you can "step through" your program to find bugs. 



DESCRIPTION:





JSTEP is used to step through your program---to execute a specified number Nof program statements. DEBUG must be ON for the STEP command to take effect. LIf DEBUG is not on and the STEP command is given, INTOUCH ignores it. STEP Nmust be given as a command. When the STEP command has been executed, INTOUCH Oissues a BREAK and prints the break message. Issuing the STEP command without 5a number causes INTOUCH to execute one program line. 

'Example 4-4 Using STEP in DEBUG System


WINTOUCH 4.2 Program: NONAME DEBUG WThe Next Generation Language Status : BREAK at 10.5  RNH 61 2 BREAK at 10.2  INTOUCH STEP 2 3 4 INTOUCH   W ^ PRINT '5' WEXIT = Exit \ = Back HELP = Help





EIssuing the STEP command with a number causes INTOUCH to execute the Enumber of program lines specified. INTOUCH begins executing program Flines from the last line executed. It stops when the number of lines =specified have been executed or when program execution ends. 

EYou must start a program with RUN or RNH before you can use the STEP statement. 



G

4.8 GO--Continuing Program Execution



-

4.8.1 GO



FORMAT:



        GO 


EXAMPLE:



        GO 


PURPOSE:





>Use GO to continue program execution after it has been interrupted. 



DESCRIPTION:





FOnce execution has stopped, you can enter immediate mode and debugger Ecommands, change code, etc. GO lets you resume execution even after Icode has been changed. If a HALT or BREAK statement was used, execution <will resume at the first statement after the HALT or BREAK. 

%Example 4-5 Using GO in DEBUG System


WINTOUCH 4.2 Program: NONAME DEBUG WThe Next Generation Language Status : BREAK at 20 10 DEBUG ON  FOR i = 1 TO 6 20 IF i = 4 THEN BREAK 30 NEXT i 40 END RNH BREAK at 20  INTOUCH PRINT SQR(i)  2  INTOUCH 25 PRINT i; GO 4 5 6 INTOUCH W WEXIT = Exit \ = Back HELP = Help




Q

Chapter 5
Inputting and Storing Terminal Data



DThis chapter describes the various ways that data can be entered at (the terminal and stored into variables. 

6

5.1 INPUT Statement



FORMAT:



!        [LINE] INPUT var, var...  .        [KEY] [LINE] INPUT [  ['Prompt_text'] (          [, PROMPT str_expr] [, ERASE] F          [, AT row, column] [, LENGTH num_expr] [, DEFAULT str_expr] H          [, VALID str_expr] [, TIMEOUT time_limit] [, ELAPSED num_var] S          [, AREA num_expr, num_expr, num_expr, num_expr] [, ATTRIBUTES attr_list] 0          [, SCREEN '[text] <format>...'] A          [, MENU str_expr: str_var] :] var [,var. . .]          


EXAMPLE:



9        10  INPUT 'Please enter your first name': first$ 5            INPUT 'Now, enter your last name': last$ 2            LINE INPUT 'Where do you live': city$         20  PRINT /            PRINT 'Hello '; first$; ' '; last$ !            PRINT 'From '; city$         30  END          RNH ,        Please enter your first name? Sunny '        Now, enter your last name? Day 1        Where do you live? San Diego, California          Hello Sunny Day #        From San Diego, California 


PURPOSE:





GUse the INPUT statement to ask questions at the terminal and store the !answers for use in your program. 





DESCRIPTION:





?The INPUT statement reads data typed by the user at the Eterminal and assigns it to variables. var is a variable that Jthe data is being assigned to. When INTOUCH executes an INPUT statement, Jit prints any prompt given and waits for the user's response. The user's 8response is then assigned to the variable(s) specified. 

JFor information on INPUT from a text file, see Chapter 15, File Handling. 

IThe user enters data at the terminal in response to the INPUT statement. FThe input data must be the same data type as the variable, or INTOUCH Egenerates an exception. If, in response to the INPUT statement, the ,user presses the Return key and: 




D

5.1.1 Types of INPUT Statements



+There are three types of INPUT statements: 



7

5.1.2 INPUT Styles



There are four input styles: 

    
  1. Simple input from the terminal. 

    2        10  INPUT 'Please enter your name': name$ "        20  PRINT 'Hello '; name$         30  END          RNH %        Please enter your name? Toby         Hello Toby 
    
  2. @Formatted data entry screens (see Section 5.16, SCREEN Option). 

    2        10  INPUT 'Please enter your name': name$ G        20  INPUT SCREEN 'Soc. sec.: <DIGITS: ###-##-####>': ssn 8        30  PRINT name$, 'Social security number:'; ssn         40  END          RNH %        Please enter your name? Fred 6        Soc. sec.:  ___-__-____        (before input) 5        Soc. sec.:  324-11-4533        (after input) >        Fred                Social security number: 324114533 
    
  3. CFree format multi-line text input (see Section 5.15, AREA Option). 

            10  CLEAR -            MESSAGE 'Press GOLD/F when done' 0        20  LINE INPUT AREA 5, 10, 8, 60: text$ -        30  PRINT AT 10, 1: 'Rewrapped text' &        40  wt$ = WRAP$(text$, 1, 30)         50  PRINT wt$         60  END          RNH  9        This is an example of wrapped text.  The text is <        wrapping.__________________________________________ <        ___________________________________________________ <        ___________________________________________________          Rewrapped text &        This is an example of wrapped %        text.  The text is wrapping. 
    
  4. .Pop-up menus (see Section 5.17, MENU Option). 

    5        10  sample_menu$ = '%TITLE "Options",' & 1                + 'Add, Change, Delete, Inquire' 5        20  LINE INPUT MENU sample_menu$: selection$ 1        30  PRINT 'Menu option was '; selection$         40  END          RNH            +--Options---+           |  ADD       |           |  CHANGE    |           |  DELETE    |           |  INQUIRE   |           +------------+          Menu option was CHANGE 
    
4

5.2 INPUT Options



LThe INPUT statement has the following options. These options are described 1in detail in following sections of this chapter. 

   %     ?     A     ;     %     H     N     1     <     T     8     b  
PROMPT displays the prompt text
AT row, col positions the cursor on the desired row and column
LENGTH nn limits the number of characters that a user can type
DEFAULT lets you provide defaults for INPUT statements
VALID validates user responses
TIMEOUT limits the time the user has to respond to the INPUT prompt
AREA does free format multi-line text input from an area on the screen
SCREEN creates formatted data entry screens
MENU displays and receives input from "pop-up" menus
ELAPSED keeps track of the time it takes the user to respond to an INPUT prompt
ATTRIBUTES displays in BOLD, BLINK, REVERSE, UNDERLINE
ERASE clears the input line prior to accepting input and after the input has been completed
Z

5.3 INPUT Commands and Keystrokes Available to the User



GAt an input prompt, there are several commands and keystrokes that the ?user can enter instead of an answer to the prompt. These are: "

EXIT or Ctrl/Z





@You can type the word EXIT or press Ctrl/Z to Fexit from a prompt or procedure. If one of these options is entered, >INTOUCH sets the internal variable _EXIT to TRUE (1). 



"

\ (backslash) or UP-arrow





/If you enter \ (backslash) or press the 7Up-arrow key, the internal variable _BACKwill be set to TRUE (1). 



HELP or Help





AYou can get help for an input item by typing the word HELPKor by pressing the Help key. If one of these options is input, =INTOUCH sets the internal variable _HELP to TRUE (1). 



JThe internal variables _BACK, _EXIT and _HELP can be examined within your -program and appropriate action can be taken. 

8

5.3.1 Editing Input



HIf the user wants to edit their input, they can use the following keys:              :     8     6         &     7     1     …  
Left-arrow move left
Right-arrow move right
Delete key delete character(s) to the left of the cursor
TAB move to next input field or terminate input
CTRL/A toggle between insert and overstrike mode
CTRL/E move to end of line
CTRL/H move to beginning of line
CTRL/J delete the word to the left of the cursor.
CTRL/U delete all the characters on a line.
Return terminate the input; you can press Return anywhere in the line, you do not have to be at the end of the line.


4


Next page... | 6Table of Contents