RESTORE
10 DIM months$(3)
DIM more_months$(3)
20 DATA January, February, March
30 FOR i = 1 TO 3
READ months$(i)
PRINT months$(i)
NEXT i
40 RESTORE
PRINT
50 FOR i = 1 TO 3
READ more_months$(i)
PRINT more_months$(i)
NEXT i
60 END
RNH
January
February
March
January
February
March
Use RESTORE when you want to use the same set of data (from a DATA statement) for a number of READ statements.
RESTORE restores the DATA statements in a program unit so that you can use them again. When the RESTORE statement is executed, all the DATA statements which have been read are restored. The next READ statement causes INTOUCH to go back to the first DATA statement and begin assigning the items in its list.
In the example program, the months will be read and assigned to the array MONTHS$. When the RESTORE is executed, the DATA statements will be restored. When the READ statement is executed, the months will be read into the new array MORE_MONTHS$.
SET and ASK statements find and change characteristics within an INTOUCH program. SET sets various characteristics, and ASK returns the value of various characteristics. SET and ASK have several different options.
You can use SET and ASK on a channel of a device. Use SET and ASK if you need to do some special printing to the terminal. You can use ASK to find the terminal's current print zone width and right margin setting. If they are not correct, you can use SET to change them and then print your material to the terminal.
Note
For information on SET #chnl and ASK #chnl statements, refer to Chapter 15, File Handling.For information on SET STRUCTURE and ASK STRUCTURE statements, refer to Chapter 14, Data Structure Statements.
SET AUTOEXIT num_expr
10 SET AUTOEXIT 1
20 DO
INPUT 'Who': a$
IF _EXIT OR _BACK THEN EXIT DO
30 LOOP
PRINT 'Finished'
40 END
RNH
Who? Greg
Who? Sammy
Who? (User fails to respond within 1 minute.)
INTOUCH
Use to slowly back a user out of a program if the terminal is left idle.
SET AUTOEXIT causes an idle terminal waiting at an input prompt to set _EXIT to TRUE and complete the input. num_expr is the length of time in minutes. If num_expr is assigned a value of 0, INTOUCH turns off the feature.
If the terminal is left idle for num_expr minutes at the input prompt, EXIT will be forced as the response, the _EXIT flag will be set on and the program will execute the code indicated for _EXIT, if any.
9.2 SET BACK ON | OFF
9.2.1 SET BACK ON
SET BACK ON
10 LINE INPUT 'Name', LENGTH 30: reply$
20 PRINT _BACK
30 SET BACK ON
40 PRINT _BACK
50 END
RNH
Name? TESTER________________________
0
1
SET BACK OFF
10 LINE INPUT 'Name', LENGTH 30: reply$
20 PRINT _BACK
30 SET BACK OFF
40 PRINT _BACK
50 END
RNH
Name? \_____________________________
1
0
9.3 SET ERROR ON | OFF
9.3.1 SET ERROR ON
SET ERROR ON
10 DO
INPUT 'Enter the age': age
IF age < 1 THEN
PRINT 'Too young:'; age
SET ERROR ON
ELSE
SET ERROR OFF
END IF
LOOP WHILE _ERROR
20 END
RNH
Enter the age? .5
Too young: .5
Enter the age? 38
Use to set the _ERROR flag on.
_ERROR is a general purpose error flag. You can use it to indicate that an error has occurred, and to test later on whether an error has occurred.
The following statements SET the _ERROR flag:
SET ERROR OFF
10 DO
INPUT 'Enter the age': age
IF age < 1 THEN
PRINT 'Too young:'; age
SET ERROR ON
ELSE
SET ERROR OFF
END IF
LOOP WHILE _ERROR
30 END
RNH
Enter the age? .5
Too young: .5
Enter the age? 38
Use to clear the _ERROR flag.
_ERROR is a general purpose error flag. You can use it to indicate that an error has occurred, and to test later on whether an error has occurred.
The following statements CLEAR the _ERROR flag:
ASK ERRORS num_var
10 DO
INPUT 'Enter the age': age
IF age < 1 THEN
MESSAGE ERROR: age; ' Too Young'
REPEAT DO
ELSE
EXIT DO
END IF
LOOP
20 ASK ERRORS num_errors
PRINT 'Errors:'; num_errors
30 END
RNH
Enter the age? 0 0 Too Young
Enter the age? .5 .5 Too Young
Enter the age? 21
Errors: 2
ASK ERRORS asks for the number of user errors. The MESSAGE ERROR: statement increments this internal counter.
9.5 SET EXIT ON | OFF
9.5.1 SET EXIT ON
SET EXIT ON
10 LINE INPUT 'Name', LENGTH 30: reply$
20 PRINT _EXIT
30 SET EXIT ON
40 PRINT _EXIT
50 END
RNH
Name? ELAINE________________________
0
1
SET EXIT OFF
10 LINE INPUT 'Name', LENGTH 30: reply$
20 PRINT _EXIT
30 SET EXIT OFF
40 PRINT _EXIT
50 END
RNH
Name? EXIT__________________________
1
0
9.6 SET HELP ON | OFF
9.6.1 SET HELP ON
SET HELP ON
10 LINE INPUT 'Name', LENGTH 30: reply$
20 PRINT _HELP
30 SET HELP ON
40 PRINT _HELP
50 END
RNH
Name? MIKE__________________________
0
1
SET HELP OFF
10 LINE INPUT 'Name', LENGTH 30: reply$
20 PRINT _HELP
30 SET HELP OFF
40 PRINT _HELP
50 END
RNH
Name? HELP__________________________
1
0
ASK KEYSTROKES num_var
10 INPUT 'Please enter your name': name$
PRINT 'Hello '; name$
20 ASK KEYSTROKES strokes
PRINT 'Keystrokes:'; strokes
30 END
RNH
Please enter your name? Maryanne
Hello Maryanne
Keystrokes: 8
ASK KEYSTROKES asks for the number of user-entered keystrokes.
9.8 ASK | SET MARGIN
9.8.1 ASK MARGIN
ASK MARGIN num_var
ASK MARGIN finds the right margin of the device specified and assigns its value to the numeric variable, num_var.
SET MARGIN num_expr
10 PRINT REPEAT$('.' ,200)
PRINT
ASK MARGIN old_marg
20 INPUT 'What do you want the margin set to': new_marg
30 SET MARGIN new_marg
40 PRINT REPEAT$('.' ,200)
SET MARGIN old_marg
50 END
RNH
..................................................
..................................................
..................................................
..................................................
What do you want the margin set to? 20
....................
....................
....................
....................
SET MARGIN sets the right margin on the device specified to the number indicated. num_expr specifies the column to set the margin to. The margin must be greater than zonewidth.
9.9 ASK | SET MESSAGELINE
9.9.1 ASK MESSAGELINE
ASK MESSAGELINE num_var
10 CLEAR
PRINT AT 1,1:;
20 ASK MESSAGELINE orig_mess_line
MESSAGE 'Current message line is '; orig_mess_line
DELAY 4
30 new_line = 12
SET MESSAGELINE new_line
MESSAGE 'New message line is '; new_line
DELAY 4
40 SET MESSAGELINE orig_mess_line
MESSAGE 'Message line has been reset to its original position'
50 END
RNH
Current message line is 23
New message line is 12
Message line has been reset to its original position
The MESSAGELINE option of the ASK statement returns the line number on which the messages are displayed. This numeric value is stored in num_var.
SET MESSAGELINE num_var
10 CLEAR
PRINT AT 1,1:;
20 ASK MESSAGELINE orig_mess_line
MESSAGE 'Current message line is '; orig_mess_line
DELAY 4
30 new_line = 12
SET MESSAGELINE new_line
MESSAGE 'New message line is '; new_line
DELAY 4
40 SET MESSAGELINE orig_mess_line
MESSAGE 'Message line has been reset to its original position'
50 END
RNH
Current message line is 23
New message line is 12
Message line has been reset to its original position
The MESSAGELINE option of the of the SET statement sets the line on which the next message is displayed. If SET MESSAGELINE 0 is used, no messages will be displayed.
ASK PAGESIZE num_var
10 ASK PAGESIZE no_lines
PRINT 'There are'; no_lines; 'lines or rows on this screen'
20 END
RNH
There are 24 lines or rows on this screen
ASK PAGESIZE returns the number of rows or lines of terminal screen output.
9.11 SET PORT ON | OFF
9.11.1 SET PORT ON
SET PORT ON
10 PRINT 'About to print to my printer port'
20 SET PORT ON
PRINT 'This is on the printer port'
SET PORT OFF
30 PRINT 'Back to the screen again'
40 END
RNH
About to print to my printer port
Back to the screen again
Allows a program to use an attached printer port on a terminal.
SET PORT ON | OFF turns the printer port ON or OFF. SET PORT ON turns on the attached port. SET PORT OFF turns off the attached port.
To indicate the type of printer that is attached to the terminal's printer port, you can use the symbol TTI_PRINTER_TYPE.
To set up the printer type, enter the following at the system prompt (DCL level):
$ TTI_PRINTER_TYPE == 'printer_type'
where "printer_type" is one of the following:
Example: $ TTI_PRINTER_TYPE :=,= 'HP'
If the symbol is not defined, the type DEC is assumed.
If a terminal has a non-DEC printer port, no escape sequences are sent to the printer when you print to the printer port.
SET PORT OFF
10 PRINT 'About to print to my printer port'
20 SET PORT ON
PRINT 'This is on the printer port'
SET PORT OFF
30 PRINT 'Back to the screen again'
40 END
RNH
About to print to my printer port
Back to the screen again
Disable printing to an attached printer port on a terminal.
SET PORT OFF turns off the attached port.
ASK RESPONSES num_var
10 INPUT 'Please enter your name': name$
INPUT 'What day is this': what_day$
PRINT 'Hello '; name$
PRINT 'Have a good '; what_day$
20 ASK RESPONSES answers
PRINT
PRINT 'Responses:'; answers
30 END
RNH
Please enter your name? Ginger
What day is this? Wednesday
Hello Ginger
Have a good Wednesday
Responses: 2
ASK RESPONSES asks for the number of completed input responses.
SET SCROLL num_expr1, num_expr2
10 FRAME OFF
PRINT AT 21, 1: 'This text will not scroll.'
SET SCROLL 5, 20
PRINT AT 20, 1:;
DELAY 1
PRINT 'This'
DELAY 1
PRINT 'text'
DELAY 1
PRINT 'will'
DELAY 1
PRINT 'scroll.'
DELAY 1
20 SET SCROLL 1,24
30 END
RNH
This
text
will
scroll
This text will not scroll.
This statement sets up a scrolling region from line num_expr1 to line num_expr2.
ASK SEED num_var
SET SEED num_expr
10 RANDOMIZE
ASK SEED seed_num
FOR i = 1 TO 3
PRINT RND(1000)
NEXT i
PRINT 'Reset the random sequence'
SET SEED seed_num
FOR i = 1 TO 3
PRINT RND(1000)
NEXT i
20 END
RNH
608
88
506
Reset the random sequence
608
88
506
Allows you to set or reset the pseudo-random number sequence.
ASK SEED returns the current starting point of a pseudo-random sequence and stores the number in num_var.
SET SEED sets the starting point of a pseudo-random sequence with the number in num_expr.
There are a number of ASK SYSTEM and SET SYSTEM statements. These are described in the following sections. The ASK/SET statements ask about and set various system operation features.
ASK SYSTEM: COMMENT str_var
10 SET SYSTEM: COMMENT 'Invoice Entry'
20 ASK SYSTEM: COMMENT c$
30 PRINT c$
40 END
RNH
Invoice Entry
The ASK SYSTEM: COMMENT statement asks for the INTOUCH operating system comment for the process.
SET SYSTEM: COMMENT str_expr
10 SET SYSTEM: COMMENT 'Invoice Entry'
20 ASK SYSTEM: COMMENT c$
30 PRINT c$
40 END
RNH
Invoice Entry
The SET SYSTEM: COMMENT statement loads the INTOUCH operating system comment area with the specified string. This statement can be used in combination with the TTI_RUN:ISHOW.COM command procedure. The INTOUCH program sets the comment to some text, such as the name of the specific routine being executed. When you run TTI_RUN:ISHOW.COM, you see the specific INTOUCH program and routine within that program being run by all INTOUCH users.
ASK SYSTEM: DIRECTORY str_var
10 ASK SYSTEM: DIRECTORY z$
PRINT 'Current directory is: '; z$
20 END
RNH
Current directory is: USER:[PAYROLL]
ASK SYSTEM: DIRECTORY asks the operating system for the current default device and directory.
SET SYSTEM: DIRECTORY str_var
10 ASK SYSTEM: DIRECTORY z0$
PRINT 'Current directory '; z0$
SET SYSTEM: DIRECTORY 'SYS$LOGIN'
ASK SYSTEM: DIRECTORY z1$
PRINT 'Directory set to '; z1$
DELAY 2
SET SYSTEM: DIRECTORY z0$
PRINT 'Directory set back to '; z0$
20 END
RNH
Current directory USER:[TESTER.INTOUCH]
Directory set to USER:[TESTER]
Directory set back to USER:[TESTER.INTOUCH]
SET SYSTEM: DIRECTORY sets the default device and directory.
9.15.5 ASK SYSTEM, LOGICAL: VALUE
ASK SYSTEM, LOGICAL str_expr: VALUE str_var
10 ASK SYSTEM, LOGICAL "SYS$SCRATCH": VALUE scr$
20 PRINT '"SYS$SCRATCH" points to: '; scr$
30 END
RNH
"SYS$SCRATCH" points to: USER:[TESTER]
ASK SYSTEM, LOGICAL asks the operating system to translate the logical name in str_expr and place the result into the variable specified by str_var.
9.15.6 SET SYSTEM, LOGICAL: VALUE
SET SYSTEM, LOGICAL str_expr1: VALUE str_expr2
10 SET SYSTEM, LOGICAL 'SYS$SCRATCH': VALUE 'USER:[TESTER]'
ASK SYSTEM, LOGICAL 'SYS$SCRATCH': VALUE z$
PRINT 'Logical set to '; z$
20 END
RNH
Logical set to USER:[TESTER]
This statement sets the operating system logical name in str_expr1 to the value in str_expr2.
ASK SYSTEM: MODE str_var
10 ASK SYSTEM: MODE process_mode$
20 PRINT 'Process Mode: '; process_mode$
30 END
RNH
Process mode: INTERACTIVE
This statement returns the mode of the process which is one of the following:
ASK SYSTEM: PARAMETER str_var
1 PROGRAM test_param.int
10 ASK SYSTEM: PARAMETER pdata$
20 PRINT 'Parameter was: '; pdata$
30 END
INTOUCH
SAVE 'test_param'
INTOUCH
parameter
------------
| |
$ INTOUCH/SOURCE test_param show parameter
Parameter was: SHOW PARAMETER
INTOUCH
ASK SYSTEM: PARAMETER returns any parameter from the command line given after the program name and places it in str_var.
ASK SYSTEM: PARAMETER lets you obtain the command line that invoked INTOUCH. The statement gives you the part of the command line after the program name.