Previous | Contents | Index |
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.
Example 4-2 Listing Statistics in DEBUG System |
---|
INTOUCH Program: NONAME STATS DEBUG The Next Generation Language Status : RUN INTOUCH LIST STATS NONAME 4-MAY-1996 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.)
4.7 BREAK and STEP
4.7.1 BREAK
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.
Example 4-3 Using BREAK in DEBUG System |
---|
INTOUCH 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.
Example 4-4 Using STEP in DEBUG System |
---|
INTOUCH 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
4.8.1 GO
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.
Example 4-5 Using GO in DEBUG System |
---|
INTOUCH 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.
5.3.1 Editing Input
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. |
If the INPUT is to a string variable, the user can enter an unquoted or a quoted string. If the user enters an unquoted string, INTOUCH ignores any leading spaces, trailing spaces, or tabs. An unquoted string cannot contain commas.
If the user enters a quoted string, INTOUCH removes the quotes, and includes any leading or trailing spaces and tabs.
10 INPUT 'Enter your name': name1$ INPUT 'Enter your name in quotes': name2$ INPUT 'Enter your name in quotes with spaces': name3$ INPUT 'Enter last name, comma, space, first name in quotes': name4$ 20 PRINT PRINT name1$ PRINT name2$ PRINT name3$ PRINT name4$ 30 END RNH Enter your name? Tony Enter your name in quotes? 'Tony' Enter your name in quotes with spaces? ' Tony ' Enter last name, comma, space, first name in quotes? 'Smith, Tony' Tony Tony Tony Smith, Tony |
5.5.1 Simple Input Statement
A single INPUT statement can be used to input several variables. The
input items and variables must be separated with commas.
10 INPUT 'Enter 3 names separated by commas': name1$, name2$, name3$ 20 PRINT PRINT name1$, name2$, name3$ 30 END RNH Enter 3 names separated by commas? Tom,Sue,George Tom Sue George |
If an INPUT statement contains a list of variables, INTOUCH asks for input until all of the variables have a value. If the user enters less data or more data than there are variables, INTOUCH generates an exception. If an exception occurs, INTOUCH restarts from the beginning.
Users can enter the data for a variable list in one of two ways.
RNH Enter 3 names separated by commas? Tom, ? Sue, ? George Tom Sue George |
Whichever method is used, INTOUCH will continue accepting input data until all the variables have values.
5.5.2 LINE INPUT Statement
A number of variables can be input with one LINE INPUT
statement. Simply list the variables separated by line terminators.
10 LINE INPUT 'Enter a comment, press Return, enter a comment': & comment_1$, comment_2$ PRINT PRINT comment_1$ PRINT comment_2$ 20 END RNH Enter a comment, press Return, enter a comment? This is first comment ? This is second comment This is first comment This is second comment |
INTOUCH asks for input until all of the variables listed have received a value.
Unlike the INPUT statement, you cannot separate answers with commas. Each variable is prompted for separately. If you include a comma in your response, the comma is just taken as part of the text.
5.6 INPUT Default Prompt and Text
By default, INTOUCH prints a question mark and a space and then waits
for the user's response. However, you can display prompt text before
the question mark. To display prompt text, enclose the prompt text in
quotes and follow it with a colon. The colon separates the prompt text
from the variable(s). The prompt text must follow the keyword INPUT and
must be separated from the variable list by a colon.
When INTOUCH executes the INPUT statement, it prints the prompt text ("Your name" in the example below) followed by a question mark and a space.
10 INPUT 'Your name': name$ 20 PRINT name$ 30 END RNH Your name? Fred Fred |
The PROMPT option displays the specified prompt text without the question mark and space.
PROMPT str_expr |
str_expr is a string expression which contains the prompt text. str_expr can be any string expression. The prompt text is separated from the variable list with a colon (:).
10 INPUT PROMPT 'Please enter your name: ': name$ 20 PRINT 'Hello '; name$ 30 END RNH Please enter your name: Jackie Hello Jackie |
Previous | Next | Contents | Index |