INTOUCH® 4GL
A Guide to the INTOUCH Language


Previous Contents Index

DESCRIPTION:

ASK WINDOW: CURRENT and SET WINDOW: CURRENT allow you to save the image of the current screen and later restore it easily. This is useful for help messages and menus, where you must temporarily change the screen and then want to restore it back to what it was.

9.16.6 ASK WINDOW: DATA

FORMAT:


        ASK WINDOW: DATA str_var 

EXAMPLE:


        10  CLEAR 
        20  PRINT AT 10, 4: 'Mary had a'; 
            PRINT AT 11, 4: 'little lamb'; 
        30  ASK WINDOW: DATA x$ 
        40  PRINT 
        50  PRINT x$ 
        60  END 
 
        RNH 
           Mary had a 
           little lamb 
        . 
        . 
        . 
 
        Mary had a 
                     little lamb 

DESCRIPTION:

This statement reads the text displayed on the whole screen into a string variable. The statement returns a <LF> delimited string. No screen attributes are stored.

9.16.7 SET WINDOW: DATA

FORMAT:


        SET WINDOW: DATA str_expr 

EXAMPLE:


        10  CLEAR 
        20  x$ = 'Mary had a' + chr$(10) + 'little lamb' 
        30  SET WINDOW: DATA x$ 
        40  END 
 
        RNH 
        Mary had a 
        little lamb 

DESCRIPTION:

This statement sets the whole screen to the specified string. This is the mirror image of ASK WINDOW: DATA str_var.

9.16.8 ASK | SET WINDOW: KEYMAP

FORMAT:


        ASK WINDOW: KEYMAP str_var 
        SET WINDOW: KEYMAP str_expr 

EXAMPLE:


        10  PRINT 'Save the current keymap, reset keymap to default value.' 
            ASK WINDOW: KEYMAP old_keymap$ 
            SET WINDOW: KEYMAP '' 
 
            PRINT 'Changing DOWN key to be the EXIT key' 
            SET WINDOW KEYSTROKE 'down': VALUE '_exit' 
            LINE INPUT 'Press the DOWN key': down$ 
 
            PRINT 'Changing dollar sign key to *' 
            SET WINDOW KEYSTROKE '$': VALUE '*' 
            LINE INPUT 'Press the dollar sign key, then RETURN': e$ 
 
            PRINT 'Restore saved keymap' 
            SET WINDOW: KEYMAP old_keymap$ 
            LINE INPUT 'Press the DOWN key': down$ 
            LINE INPUT 'Press the dollar sign key, then RETURN' : e$ 
        20  END 
 
        RNH 
        Save the current keymap, reset keymap to default value. 
        Changing DOWN key to be the EXIT key 
        Press the DOWN key? EXIT 
        Changing dollar sign key to * 
        Press the dollar sign key, then RETURN? * 
        Restore saved keymap 
        Press the DOWN key? 
        Press the dollar sign key, then RETURN? $ 
 
        INTOUCH 

PURPOSE:

To allow a generalized routine to save the current keymap, change the meaning of keys, and then restore the original keymap when done.

DESCRIPTION:

ASK WINDOW: KEYMAP and SET WINDOW: KEYMAP allow you to save the image of the keymap and later restore it. This is helpful for applications where you must temporarily change the meaning of the keys using the SET WINDOW KEYSTROKE statement. You can restore the keymap to its default setting by using SET WINDOW: KEYMAP.

9.16.9 SET WINDOW KEYSTROKE: VALUE

FORMAT:


        SET WINDOW KEYSTROKE str_expr1: VALUE str_expr2 

EXAMPLE:


        10  PRINT 'Saving the current keymap.' 
            ASK WINDOW: KEYMAP old_keymap$ 
            SET WINDOW: KEYMAP '' 
 
            PRINT 'Changing DOWN key to be the EXIT key' 
            SET WINDOW KEYSTROKE 'down': VALUE '_exit' 
            LINE INPUT 'Press the DOWN key': down$ 
 
            PRINT 'Changing dollar sign key to *' 
            SET WINDOW KEYSTROKE '$': VALUE '*' 
            LINE INPUT 'Press the dollar sign key, then RETURN': e$ 
 
            PRINT 'Restoring saved keymap.' 
            SET WINDOW: KEYMAP old_keymap$ 
            LINE INPUT 'Press the DOWN key': down$ 
            LINE INPUT 'Press the dollar sign key, then RETURN' : e$ 
        20  END 
 
        RNH 
        Saving the current keymap. 
        Changing DOWN key to be the EXIT key 
        Press the DOWN key? EXIT 
        Changing dollar sign key to * 
        Press the dollar sign key, then RETURN? * 
        Restoring saved keymap. 
        Press the DOWN key? 
        Press the dollar sign key, then RETURN? $ 
 
        INTOUCH 

PURPOSE:

SET WINDOW KEYSTROKE allows you to change the meaning of a keystroke within an INTOUCH program. This allows you to completely redefine the keyboard for a given application.

DESCRIPTION:

str_expr1 describes the name of the key that you want to change. It can be a single keystroke name, or a comma separated list of names. Keystroke names can be a single letter, or the name of the letter (such as [Tab], or [Ctrl/Z]).

str_expr2 defines the new meaning of the keystroke. A keystroke meaning consists of one or two components. The keystroke value, and the keystroke concept. For example, the [Ctrl/Z] key usually has a value of CHR$(26), and the concept of EXIT. The keystroke value and/or the keystroke concept can be changed. If changing both a value and a concept, separate the two with a comma. You can restore the original meaning of the key by using " ".

The following keystroke concepts are supported:

Table 9-1 Supported Keystroke Concepts
Concept name Description
_EXIT an EXIT key
_BACK a BACK key
_HELP a HELP key
_IGNORE ignore this keystroke
_INVALID beep when pressed
_TERMINATOR keystroke is a line terminator

9.16.10 ASK WINDOW: ROW

FORMAT:


        ASK WINDOW: ROW num_var 

EXAMPLE:


        10  CLEAR 
            PRINT AT 5,10:; 
        20  ASK WINDOW: ROW cur_row 
        30  PRINT 'Cursor is at row'; cur_row 
        40  END 
 
        RNH 
        Cursor is at row 5 

DESCRIPTION:

This statement returns the current row of the cursor's position.

9.16.11 SET WINDOW: ROW

FORMAT:


        SET WINDOW: ROW num_expr 

EXAMPLE:


        10  CLEAR 
        20  SET WINDOW: ROW 3 
        30  PRINT 'Hi!' 
        40  END 
 
        RNH 
 
        Hi! 

DESCRIPTION:

This statement positions the cursor at the num_expr row within the current column.

9.16.12 ASK WINDOW: TYPEAHEAD

FORMAT:


        ASK WINDOW: TYPEAHEAD str_var 

EXAMPLE:


        10  DO 
              GOSUB process 
              ASK WINDOW: TYPEAHEAD z$ 
              IF  POS(UCASE$(z$), 'STA') > 0  THEN  GOSUB show_status 
              IF  POS(z$, CHR$(26)) > 0  THEN  EXIT DO 
            LOOP 
            STOP 
 
            ROUTINE process 
              DELAY 1                     ! simulated processing 
              PRINT '.'; 
            END ROUTINE 
 
            ROUTINE show_status 
              PRINT 
              PRINT 'Showing status' 
              SET WINDOW: TYPEAHEAD '' 
            END ROUTINE 
        20  END 
 
        RNH 
        .......       (type STA) 
        showing status 
        .......       (press [CTRL/Z] ) 

DESCRIPTION:

ASK WINDOW: TYPEAHEAD gets data from the typeahead buffer. You can use this statement to determine, for example, whether the user has typed [Ctrl/Z] or other special keystrokes. Asking for typeahead data does not lose what is already in the typeahead buffer.

9.16.13 SET WINDOW: TYPEAHEAD

FORMAT:


        SET WINDOW: TYPEAHEAD str_expr 

EXAMPLE:


        10  SET WINDOW: TYPEAHEAD 'FRED' + CHR$(13) 
            INPUT 'Name': name$ 
            PRINT name$ 
        20  END 
 
        RNH 
        Name? FRED 
        FRED 

DESCRIPTION:

SET WINDOW: TYPEAHEAD puts data into the typeahead buffer as though the user had typed the data in from the terminal.

9.17 ASK | SET ZONEWIDTH

9.17.1 ASK ZONEWIDTH

FORMAT:


        ASK ZONEWIDTH num_var 

EXAMPLE:


        10  ASK ZONEWIDTH x 
            PRINT 'The current print zone width is'; x 
        20  END 
 
        RNH 
        The current print zone width is 20 

DESCRIPTION:

ASK ZONEWIDTH finds the print zone width of the device specified and assigns the value to the numeric variable, num_var.

9.17.2 SET ZONEWIDTH

FORMAT:


        SET ZONEWIDTH num_expr 

EXAMPLE:


        10  PRINT 1,2,3                                           
        20  SET ZONEWIDTH 10                                          
            PRINT 1,2,3                                               
        30  SET ZONEWIDTH 20 
        40 END                                                       
        RNH                                                          
        1                   2                   3                    
        1         2         3                                        

DESCRIPTION:

SET ZONEWIDTH sets the print zone width of the device specified to the number designated. num_expr indicates the width to set the device's print zones.


Chapter 10
Defining Arrays

Arrays are a type of variable. They are used to store and manipulate tables of variable information. An array must be defined before it is used in a program. Array variables are described in Section 3.2.5.1, Arrays.

10.1 Dimensioning Arrays

Arrays are dimensioned with a DIM statement. The REDIM statement can be used to redimension an array--that is, to change the dimensions of an array which has been defined with the DIM statement. The OPTION BASE statement changes the default low bound. By default, the low bound is 1.

About arrays:

10.1.1 DIM

FORMAT:


        DIM [INTEGER | REAL | STRING] 
                  array_name ([int_expr TO] int_expr [, ...]) 

EXAMPLE:


        10  DIM name$(4) 
        20  FOR i = 1 TO 4 
              INPUT 'Enter a name': name$(i) 
            NEXT i 
        30  PRINT 
        40  FOR i = 1 TO 4 
              PRINT i; ' '; name$(i) 
            NEXT i 
        50  END 
 
        RNH 
        Enter a name? Jim 
        Enter a name? Jane 
        Enter a name? Bob 
        Enter a name? Betty 
 
         1  Jim 
         2  Jane 
         3  Bob 
         4  Betty 

PURPOSE:

Use DIM to dimension arrays. Arrays are used to store tables of variable information. You must dimension an array before you can use it.

DESCRIPTION:

The simplest version of a DIM statement is:


        DIM array_name(int_expr) 

array_name is the name of the array being defined. The array name must meet the rules for variable names. int_expr is the high bound for the array---the highest element allowed in a dimension. The low bound is the lowest element allowed in a dimension. The low bound defaults to 1. For example:


        DIM NAME$(4) 

This statement defines a one-dimensional array with four elements:


        NAME$(1) 
        NAME$(2) 
        NAME$(3) 
        NAME$(4) 

Multiple Dimensions

An array can have up to 32 dimensions. A high bound must be specified for each dimension.


        DIM array_name(int_expr [, int_expr, ...]) 

For example:


        10  DIM name$(4,2) 

This statement defines the following two-dimensional array:


        NAME$(1,1)   NAME$(1,2) 
        NAME$(2,1)   NAME$(2,2) 
        NAME$(3,1)   NAME$(3,2) 
        NAME$(4,1)   NAME$(4,2) 

?8pc Low Bounds

The low bound is the lowest element a dimension can have. Low bounds can be specified for each dimension of an array. If no low bound is specified, the default is 1. To specify a low bound, use the following format:


        DIM array_name (int_ expr TO int_expr) 

The number preceding TO is the low bound. For example:


        10  DIM name$(4,18 TO 20) 

This statement creates an array whose first dimension contains elements 1-4 and whose second dimension contains elements 18-20:


        NAME$(1,18)   NAME$(1,19)   NAME$(1,20)   
        NAME$(2,18)   NAME$(2,19)   NAME$(2,20)   
        NAME$(3,18)   NAME$(3,19)   NAME$(3,20)   
        NAME$(4,18)   NAME$(4,19)   NAME$(4,20)   

10.1.2 REDIM

FORMAT:


        REDIM array_name (int_expr, int_expr...) ... 
 
             OR 
 
        REDIM array_name [( [int_expr TO] int_expr, 
                      [int_expr TO] int_expr... )] ... 

EXAMPLE:


        10  DIM name$(2) 
            INPUT 'How many names': num 
            REDIM name$(num) 
        20  FOR i = 1 TO num 
              INPUT 'Enter a name': name$(i) 
            NEXT i 
        30  DO 
              PRINT 
              FOR i = 1 TO num 
                IF  name$(i) = ''  THEN 
                  PRINT i; ' '; 'empty slot' 
                ELSE 
                  PRINT i; ' '; name$(i) 
                END IF 
              NEXT i 
              PRINT 
              INPUT 'How many names': num 
              IF  _BACK  or  _EXIT  THEN  EXIT DO 
              REDIM name$(num) 
            LOOP 
        40  END 
 
        RNH 
        How many names? 3 
        Enter a name? Tim 
        Enter a name? Sammy 
        Enter a name? Fred 
 
         1  Tim 
         2  Sammy 
         3  Fred 
 
        How many names? 4 
 
         1  Tim 
         2  Sammy 
         3  Fred 
         4  empty slot 
 
        How many names? exit 

PURPOSE:

The REDIM statement is used to change the size of an array.

DESCRIPTION:

REDIM redimensions arrays. REDIM can only be used on arrays that have already been dimensioned with the DIM statement. The REDIM statement has the same rules, options and limits as the DIM statement.

You can dynamically expand arrays as needed. If you REDIM a single dimension array or the first dimension of a multi dimensioned array to a larger size, the old values are kept. If you REDIM any array to a smaller size or REDIM two or more dimensions in a multi dimensioned array to a larger size, the old values are lost.

If your application depends on REDIM initializing all array values, change your code as follows:


        Old Code:       REDIM X(100) 
 
        New Code:       REDIM X(1) 
                        REDIM X(100) 

The REDIM X(1) forces all array values to be initialized by the second REDIM statement.

10.1.3 OPTION BASE

FORMAT:


        OPTION BASE [0 | 1] 

EXAMPLE:


        10  OPTION BASE 0 
            DIM name$(4) 
        20  FOR i = 0 TO 4 
              INPUT 'Enter a name': name$(i) 
              PRINT i; ' Hello, '; name$(i) 
            NEXT i 
        30  END 
 
        RNH 
        Enter a name? June 
         0  Hello, June 
        Enter a name? Tony 
         1  Hello, Tony 
        Enter a name? Sandy 
         2  Hello, Sandy 
        Enter a name? Carl 
         3  Hello, Carl 
        Enter a name? Liz 
         4  Hello, Liz 

PURPOSE:

Use OPTION BASE to set the default low bound for arrays to suit your needs. You have the option of starting the array with element O or element 1.

DESCRIPTION:

When no low bound is specified for a dimension, the default is 1. The OPTION BASE statement lets you specify a default low bound of 0 or 1. When any following DIM or REDIM statements are executed, INTOUCH defaults the low bound to 0 or 1 as specified.


Previous Next Contents Index