INTOUCH® 4GL
A Guide to the INTOUCH Language


Previous Contents Index

8.5 LSET, RSET, CSET FILL

FORMAT:


        LSET | RSET | CSET FILL str_expr: str_var = expr 

EXAMPLE:


        10  heading$ = REPEAT$('.', 20)          ! Twenty dots 
        20  PRINT '('; heading$; ')' 
        30  CSET FILL '*': heading$ = 'Page 12' 
            PRINT '('; heading$; ')' 
        40  END 
 
        RNH 
        (....................) 
        (*******Page 12******) 

DESCRIPTION:

The value of expr is left-justified, right-justified or centered inside the str_var. The remaining part of the string is filled with the pattern specified by str_expr. If str_expr is the null string, no filling occurs---the remaining part of the string is left as is.

8.6 DATA, READ, RESTORE Statements

8.6.1 READ

FORMAT:


        DATA [num_const | str_const] [,[num_const | str_const]...] 
                      . 
                      . 
                      . 
        READ [num_var | str_var] [,[num_var | str_var]...] 

EXAMPLE:


        10  DIM months$(6) 
        20  DATA January, February, March 
        30  DATA April, May, June 
        40  FOR i = 1 TO 6 
              READ months$(i) 
              PRINT months$(i) 
            NEXT i 
        50  END 
 
        RNH 
        January 
        February 
        March 
        April 
        May 
        June 

PURPOSE:

Use DATA and READ statements to assign data to variables in cases where the data will not change with successive runs of the program.

DESCRIPTION:

The READ and DATA statements assign data to variables. DATA specifies a list of data to assign. The data must be given as constants and can be string, numeric or integer types. Multiple data items must be separated by commas.

The READ statement specifies a list of variables to assign data to. The variables can be string, numeric or integer variables. They can be substrings, array elements, etc..

When INTOUCH executes the first READ statement, it goes to the first DATA statement and assigns the items in the DATA list to the variables in the READ list. The first variable in the READ list is assigned the first value in the DATA list. The second variable in the READ list is assigned the second value in the DATA list, and so on.


        DATA constant, constant, constant, constant... 
        .          
        .       |         |         |         | 
        .                                   
        READ variable, variable, variable, variable... 

If the data item contains a commas, the data item should be enclosed with single or double quotes. For example:


        10  DIM amounts$(3) 
        20  DATA '$25,000', '$250,000', '$2,500,000' 
        30  READ amounts$(1), amounts$(2), amounts$(3) 
        40  PRINT amounts$(1), amounts$(2), amounts$(3) 
        50  END 
 
        RNH 
        $25,000             $250,000            $2,500,000 

The variable types and data types must match or an exception will result. For example, if the third item in the DATA list is a string constant, and the third variable in the READ list is a numeric variable, an exception will result.

When the second READ statement is executed, INTOUCH starts reading from the first unread data item in the DATA list. For example:


         10  DIM months$(4) 
         20  DATA January, February, March, April, May, June 
         30  READ months$(1), months$(2) 
         40  READ months$(3), months$(4) 
         50  PRINT months$(1), months$(2), months$(3), months$(4) 
         60  END 
 
         RNH 
         January     February      March      April 

In the example above, when the first READ statement is executed, INTOUCH reads the months January and February. When the second READ statement is executed, INTOUCH will continue at the first unread month--March--and read it into months$(3).

If you attempt to read more data than exists, that is, if your READ list has more items than than your DATA list, an exception will result. You can avoid this by using the RESTORE statement to restore the DATA list and read from the beginning again.

The READ and DATA statements must occur in the same program unit. For example, you cannot not have your DATA statements in the main program unit and your matching READ statements in a subprogram.

See Section 8.6.2 for information on using RESTORE.

8.6.2 RESTORE

FORMAT:


        RESTORE 

EXAMPLE:


        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 

PURPOSE:

Use RESTORE when you want to use the same set of data (from a DATA statement) for a number of READ statements.

DESCRIPTION:

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$.


Chapter 9
Set and Ask Statements

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.

9.1 SET AUTOEXIT

FORMAT:


        SET AUTOEXIT num_expr 

EXAMPLE:


        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 

PURPOSE:

Use to slowly back a user out of a program if the terminal is left idle.

DESCRIPTION:

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

FORMAT:


        SET BACK ON 

EXAMPLE:


        10  LINE INPUT 'Name', LENGTH 30: reply$ 
        20  PRINT _BACK 
        30  SET BACK ON 
        40  PRINT _BACK 
        50  END 
 
        RNH 
        Name? TESTER________________________ 
        0 
        1 

DESCRIPTION:

SET BACK ON sets the internal variable _BACK to TRUE (1).

9.2.2 SET BACK OFF

FORMAT:


        SET BACK OFF 

EXAMPLE:


        10  LINE INPUT 'Name', LENGTH 30: reply$ 
        20  PRINT _BACK 
        30  SET BACK OFF 
        40  PRINT _BACK 
        50  END 
 
        RNH 
        Name? \_____________________________ 
        1 
        0 

DESCRIPTION:

SET BACK OFF sets the internal variable _BACK to FALSE (0).

9.3 SET ERROR ON | OFF

9.3.1 SET ERROR ON

FORMAT:


        SET ERROR ON 

EXAMPLE:


        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 

PURPOSE:

Use to set the _ERROR flag on.

DESCRIPTION:

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

9.3.2 SET ERROR OFF

FORMAT:


        SET ERROR OFF 

EXAMPLE:


        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 

PURPOSE:

Use to clear the _ERROR flag.

DESCRIPTION:

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

9.4 ASK ERRORS

FORMAT:


        ASK ERRORS num_var 

EXAMPLE:


        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 

DESCRIPTION:

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

FORMAT:


        SET EXIT ON 

EXAMPLE:


        10  LINE INPUT 'Name', LENGTH 30: reply$ 
        20  PRINT _EXIT 
        30  SET EXIT ON 
        40  PRINT _EXIT 
        50  END 
 
        RNH 
        Name? ELAINE________________________ 
         0 
         1 

DESCRIPTION:

SET EXIT ON sets the internal variable _EXIT to TRUE (1).

9.5.2 SET EXIT OFF

FORMAT:


        SET EXIT OFF 

EXAMPLE:


        10  LINE INPUT 'Name', LENGTH 30: reply$ 
        20  PRINT _EXIT 
        30  SET EXIT OFF 
        40  PRINT _EXIT 
        50  END 
 
        RNH 
        Name? EXIT__________________________ 
         1 
         0 

DESCRIPTION:

SET EXIT OFF sets the internal variable _EXIT to FALSE (0).

9.6 SET HELP ON | OFF

9.6.1 SET HELP ON

FORMAT:


        SET HELP ON 

EXAMPLE:


        10  LINE INPUT 'Name', LENGTH 30: reply$ 
        20  PRINT _HELP 
        30  SET HELP ON 
        40  PRINT _HELP 
        50  END 
 
        RNH 
        Name? MIKE__________________________ 
         0 
         1 

DESCRIPTION:

SET HELP ON sets the internal variable _HELP to TRUE (1).

9.6.2 SET HELP OFF

FORMAT:


        SET HELP OFF 

EXAMPLE:


        10  LINE INPUT 'Name', LENGTH 30: reply$ 
        20  PRINT _HELP 
        30  SET HELP OFF 
        40  PRINT _HELP 
        50  END 
 
        RNH 
        Name? HELP__________________________ 
         1 
         0 

DESCRIPTION:

SET HELP OFF sets the internal variable _HELP to FALSE (0).

9.7 ASK KEYSTROKES

FORMAT:


         ASK KEYSTROKES num_var 

EXAMPLE:


        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 

DESCRIPTION:

ASK KEYSTROKES asks for the number of user-entered keystrokes.

9.8 ASK | SET MARGIN

9.8.1 ASK MARGIN

FORMAT:


        ASK MARGIN num_var 

DESCRIPTION:

ASK MARGIN finds the right margin of the device specified and assigns its value to the numeric variable, num_var.

9.8.2 SET MARGIN

FORMAT:


        SET MARGIN num_expr 

EXAMPLE:


        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 
        .................... 
        .................... 
        .................... 
        .................... 

DESCRIPTON:

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

FORMAT:


        ASK MESSAGELINE num_var 

EXAMPLE:


        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 

DESCRIPTION:

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.

9.9.2 SET MESSAGELINE

FORMAT:


        SET MESSAGELINE num_var 

EXAMPLE:


        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 

DESCRIPTION:

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.

9.10 ASK PAGESIZE

FORMAT:


        ASK PAGESIZE num_var 

EXAMPLE:


        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 

DESCRIPION:

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

FORMAT:


        SET PORT ON 


Previous Next Contents Index