RANDOMIZE
10 RANDOMIZE 20 x = RND PRINT x 30 END RNH .244013674718 INTOUCH RNH .524856061388
RANDOMIZE gives the RND function a new starting point. This ensures that you will get a different random number sequence each time your program executes.
INTOUCH uses a list of random numbers when the RND function is used. If no RANDOMIZE statement is used, INTOUCH starts at the same place in this list each time the program executes. This means the same series of random numbers is returned each time the program executes.
RANDOMIZE tells INTOUCH to pick a random starting point in the list. This ensures that a different series of random numbers is returned each time the program executes. (See RND for information on the RND function.)
INTOUCH detects and announces run-time and compile-time errors. Sometimes errors occur which don't prevent execution, but cause a program to execute incorrectly. INTOUCH provides a high-level DEBUG system for detecting these more subtle errors.
DEBUG ON enables INTOUCH's Debug System. DEBUG OFF disables the system. When DEBUG is enabled, a DEBUG flag will appear at the status message in the upper right corner of the INTOUCH screen. When DEBUG is disabled, the flag 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.
Some DEBUG features automatically switch DEBUG ON or OFF when they are executed. Others require that DEBUG be enabled. (See DEBUG ON.)
Note
Using the debugging facilities impacts the INTOUCH system's performance. The system has been designed for optimal performance in a normal production environment. Therefore, DEBUG will slow INTOUCH response time.
DEBUG ON
DEBUG ON 1050 DEBUG ON
Use DEBUG ON to enable INTOUCH's debug system. The DEBUG system helps you find problems in the way your program runs. You must enable the system in order to use its features.
When DEBUG is enabled, all of INTOUCH's DEBUG features are available. DEBUG remains enabled until a DEBUG OFF command or statement is executed or until a DEBUG feature is executed which disables it.
DEBUG ON can be issued in immediate mode or as a statement in a program. If DEBUG ON is used in a program, INTOUCH enables DEBUG when it encounters the 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.
DEBUG OFF
DEBUG OFF 1050 DEBUG OFF
Use DEBUG OFF to disable INTOUCH's DEBUG system. You should turn DEBUG OFF when you have finished correcting your program.
DEBUG OFF can be issued in immediate mode or as a statement in a program. If DEBUG OFF is used in a program, INTOUCH disables DEBUG when it encounters the DEBUG OFF statement.
DEBUG will remain disabled until a DEBUG ON statement is executed, or until a DEBUG feature is executed which enables it.
4.5 Monitoring Program Execution
DEBUG's TRACE and STATISTICS features monitor your program's execution. These features take effect only during program execution.
TRACE traces your program line by line as it executes. TRACE lists the number of each program line as it is executed. STATISTICS records information on your program's execution. It records the time each program line takes to execute and the number of times the line is executed. The word "STATISTICS" can be abbreviated to "STATS" (STATS ON, STATS OFF, LIST STATS). This abbreviation will be used frequently in this Guide.
4.6 The TRACE and STATISTICS Features
Both 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$
The TRACE feature notes these program lines by line number. For instance:
10 PRINT a$ --- 10
If 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
In the example above, the first line is noted as 10. The program line following the first line is 10.1. The next line is 10.2 and so on. Labels are noted in the same way. For example:
10 show: PRINT a$ --- SHOW PRINT b$ --- SHOW.1 PRINT c$ --- SHOW.2
TRACE ON
TRACE ON 1050 TRACE ON
Use TRACE ON to turn INTOUCH's trace feature on. The trace feature lists the number of each program line as it is executed. Use TRACE to see if your statements are being executed in the correct order and the correct number of times.
To use TRACE, you must have the frame on.
TRACE ON enables INTOUCH's trace feature. The trace feature lists each program line as it is executed. TRACE ON can be executed as a command or as a statement. If TRACE ON is executed as a command, DEBUG is automatically switched on. If TRACE ON is executed as a statement, and DEBUG is off, INTOUCH 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 PRINT 'Hello, '; name$(i); '!' NEXT i 20 END
INTOUCH 4.2 Program: NONAME DEBUG The Next Generation Language Status : RUN INTOUCH TRACE ON INTOUCH RNH Please enter your name? John Hello, John! Please enter your name? [10] [MAIN] [MAIN.1] [MAIN.2] [MAIN.3] [MAIN.4] [MAIN.1] EXIT = Exit \ = Back HELP = Help
The trace remains in effect until a TRACE OFF command or statement is executed. When program execution stops, the trace stops. If program execution continues and the TRACE ON command is still in effect, the trace continues.
TRACE OFF
TRACE OFF 1050 TRACE OFF
Use TRACE OFF to turn the trace feature off.
TRACE OFF disables the trace feature. INTOUCH stops listing program line numbers when TRACE OFF is executed. If TRACE OFF is executed as a statement in a program and DEBUG is off, INTOUCH ignores the statement.
STATS ON
STATS ON 1020 STATS ON
Use STATS ON to turn on the statistics feature, which stores the execution time and count for each program line. Use STATS to tell if your statements are being executed the correct number of times and which parts of your program are taking the most time. STATS is especially useful for speeding up your program's execution time.
STATS ON enables INTOUCH's statistics feature. INTOUCH begins recording statistics when program execution begins. The statistics feature remains enabled until the STATS OFF statement is executed.
STATS ON can be executed in immediate mode or in a program. If STATS ON is executed in immediate mode, DEBUG is automatically switched on. If STATS ON is executed in a program, and DEBUG is off, INTOUCH ignores the statement. When STATS ON is executed, any statistics previously recorded are lost.
STATS OFF
STATS OFF 1020 STATS OFF
Use STATS OFF to turn off the statistics feature.
STATS OFF turns off INTOUCH's statistics feature. STATS OFF can be executed 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.
LIST STATS [:label | line_num [- | ,] label | line_num...]
LIST STATS
Use LIST STATS to display the statistics recorded by the STATISTICS feature.
LIST STATS lists each program line along with the number of times the line was executed and the execution time of each line.
INTOUCH 4.2 Program: NONAME STATS DEBUG The Next Generation Language Status : RUN INTOUCH LIST STATS NONAME 4-MAY-1995 00:54 1 0.00 10 DIM name$(5) 1 0.00 MAIN: FOR i = 1 TO 5 5 16.64 INPUT 'Please enter your name': name$(i) 5 0.00 IF _EXIT THEN EXIT FOR 5 0.00 PRINT 'Hello, '; name$(i); '!' 5 0.00 NEXT i 1 0.00 20 END INTOUCH EXIT = Exit \ = Back HELP = Help
The far-left column lists the number of times each statement was executed. The next column gives the time each statement took to execute. The time is given in seconds and fractions of a second. (0.01 means the program line was executed in one-one hundredth of a second.) The last column lists the program itself. STATS must be ON for LIST STATS to be executed.
All the options available with the "LIST" statement are also available with LIST STATS. (See Section 2.3.7, LIST for listing information.)
BREAK
1050 BREAK
Use BREAK to stop program execution when DEBUG is ON. For instance, you might use BREAK to stop the program if a variable is assigned a wrong value.
The BREAK statement can be used anywhere in a program. The BREAK statement will not take effect unless DEBUG is turned on. If DEBUG is off, INTOUCH ignores any BREAK statements.
When INTOUCH executes a BREAK statement, it interrupts program execution and prints a BREAK message. The BREAK message tells what line the break occurred in. Program execution can be continued with the GO or STEP commands.
INTOUCH 4.2 Program: NONAME DEBUG The 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 1 2 BREAK at 10.2 INTOUCH EXIT = Exit \ = Back HELP = Help
STEP [number]
STEP STEP 10
Use STEP to execute a specific number of program statements and then stop execution. That way, you can "step through" your program to find bugs.
STEP is used to step through your program---to execute a specified number of program statements. DEBUG must be ON for the STEP command to take effect. If DEBUG is not on and the STEP command is given, INTOUCH ignores it. STEP must be given as a command. When the STEP command has been executed, INTOUCH issues a BREAK and prints the break message. Issuing the STEP command without a number causes INTOUCH to execute one program line.
INTOUCH 4.2 Program: NONAME DEBUG The Next Generation Language Status : BREAK at 10.5 RNH 1 2 BREAK at 10.2 INTOUCH STEP 2 3 4 INTOUCH PRINT '5' EXIT = Exit \ = Back HELP = Help
Issuing the STEP command with a number causes INTOUCH to execute the number of program lines specified. INTOUCH begins executing program lines from the last line executed. It stops when the number of lines specified have been executed or when program execution ends.
You must start a program with RUN or RNH before you can use the STEP statement.
4.8 GO--Continuing Program Execution
GO
GO
Use GO to continue program execution after it has been interrupted.
Once execution has stopped, you can enter immediate mode and debugger commands, change code, etc. GO lets you resume execution even after code has been changed. If a HALT or BREAK statement was used, execution will resume at the first statement after the HALT or BREAK.
INTOUCH 4.2 Program: NONAME DEBUG The 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 EXIT = Exit \ = Back HELP = Help
This chapter describes the various ways that data can be entered at the terminal and stored into variables.
[LINE] INPUT var, var... [KEY] [LINE] INPUT [ ['Prompt_text'] [, PROMPT str_expr] [, ERASE] [, AT row, column] [, LENGTH num_expr] [, DEFAULT str_expr] [, VALID str_expr] [, TIMEOUT time_limit] [, ELAPSED num_var] [, AREA num_expr, num_expr, num_expr, num_expr] [, ATTRIBUTES attr_list] [, SCREEN '[text] <format>...'] [, MENU str_expr: str_var] :] var [,var. . .]
10 INPUT 'Please enter your first name': first$ INPUT 'Now, enter your last name': last$ 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 Where do you live? San Diego, California Hello Sunny Day From San Diego, California
Use the INPUT statement to ask questions at the terminal and store the answers for use in your program.
The INPUT statement reads data typed by the user at the terminal and assigns it to variables. var is a variable that the data is being assigned to. When INTOUCH executes an INPUT statement, it prints any prompt given and waits for the user's response. The user's response is then assigned to the variable(s) specified.
For information on INPUT from a text file, see Chapter 15, File Handling.
The user enters data at the terminal in response to the INPUT statement. The input data must be the same data type as the variable, or INTOUCH generates an exception. If, in response to the INPUT statement, the user presses the Return key and:
5.1.1 Types of INPUT Statements
There are three types of INPUT statements:
There are four input styles:
10 INPUT 'Please enter your name': name$ 20 PRINT 'Hello '; name$ 30 END RNH Please enter your name? Toby Hello Toby
10 INPUT 'Please enter your name': name$ 20 INPUT SCREEN 'Soc. sec.: <DIGITS: ###-##-####>': ssn 30 PRINT name$, 'Social security number:'; ssn 40 END RNH Please enter your name? Fred Soc. sec.: ___-__-____ (before input) Soc. sec.: 324-11-4533 (after input) Fred Social security number: 324114533
10 CLEAR MESSAGE 'Press GOLD/F when done' 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 This is an example of wrapped text. The text is wrapping.__________________________________________ ___________________________________________________ ___________________________________________________ Rewrapped text This is an example of wrapped text. The text is wrapping.
10 sample_menu$ = '%TITLE "Options",' & + 'Add, Change, Delete, Inquire' 20 LINE INPUT MENU sample_menu$: selection$ 30 PRINT 'Menu option was '; selection$ 40 END RNH +--Options---+ | ADD | | CHANGE | | DELETE | | INQUIRE | +------------+ Menu option was CHANGE
The INPUT statement has the following options. These options are described in detail in following sections of this chapter.
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 |
At an input prompt, there are several commands and keystrokes that the user can enter instead of an answer to the prompt. These are:
You can type the word EXIT or press Ctrl/Z to exit from a prompt or procedure. If one of these options is entered, INTOUCH sets the internal variable _EXIT to TRUE (1).
If you enter \ (backslash) or press the Up-arrow key, the internal variable _BACK will be set to TRUE (1).
You can get help for an input item by typing the word HELP or by pressing the Help key. If one of these options is input, INTOUCH sets the internal variable _HELP to TRUE (1).
The internal variables _BACK, _EXIT and _HELP can be examined within your program and appropriate action can be taken.
If the user wants to edit their input, they can use the following keys:
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. |