M!INTOUCH® 4GL Y

INTOUCH® 4GL
A Guide to the INTOUCH Language

A
Previous page... 6Table of Contents
8

5.4 Inputting Strings



HIf the INPUT is to a string variable, the user can enter an unquoted or Ia quoted string. If the user enters an unquoted string, INTOUCH ignores Iany leading spaces, trailing spaces, or tabs. An unquoted string cannot contain commas. 

DIf the user enters a quoted string, INTOUCH removes the quotes, and 2includes any leading or trailing spaces and tabs. 

,        10  INPUT 'Enter your name': name1$ 6            INPUT 'Enter your name in quotes': name2$ B            INPUT 'Enter your name in quotes with spaces': name3$ P            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  ' K        Enter last name, comma, space, first name in quotes? 'Smith, Tony'  
        Tony 
        Tony           Tony         Smith, Tony 
C

5.5 Inputting Multiple Variables



A

5.5.1 Simple Input Statement



FA single INPUT statement can be used to input several variables. The 9input items and variables must be separated with commas. 

N        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  7        Tom                 Sue                 George 


KIf an INPUT statement contains a list of variables, INTOUCH asks for input Juntil all of the variables have a value. If the user enters less data or Kmore data than there are variables, INTOUCH generates an exception. If an 7exception occurs, INTOUCH restarts from the beginning. 

BUsers can enter the data for a variable list in one of two ways. 



    L
  1. The user can enter each piece of data on a separate line by typing a Fcomma as the last character on each continuing line. The comma tells )INTOUCH that there is more data to come. 

            RNH 0        Enter 3 names separated by commas? Tom,         ? Sue,         ? George  7        Tom                 Sue                 George 
    O
  2. Users can enter the data on one line by separating the data with commas %as shown in the first example above. 


KWhichever 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 INPUTEstatement. Simply list the variables separated by line terminators. 

O        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 N        Enter a comment, press Return, enter a comment? This is first comment !        ? This is second comment          This is first comment         This is second comment 


IINTOUCH asks for input until all of the variables listed have received a value. 

EUnlike the INPUT statement, you cannot separate answers with commas. EEach variable is prompted for separately. If you include a comma in <your response, the comma is just taken as part of the text. 

D

5.6 INPUT Default Prompt and Text



FBy default, INTOUCH prints a question mark and a space and then waits Ffor the user's response. However, you can display prompt text before Gthe question mark. To display prompt text, enclose the prompt text in Hquotes and follow it with a colon. The colon separates the prompt text Ifrom the variable(s). The prompt text must follow the keyword INPUT and 5must be separated from the variable list by a colon. 

EWhen INTOUCH executes the INPUT statement, it prints the prompt text L("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 
4

5.7 PROMPT Option



<The PROMPT option displays the specified prompt text ,without the question mark and space. 

FORMAT:



        PROMPT str_expr 


Gstr_expr is a string expression which contains the prompt text. Bstr_expr can be any string expression. The prompt text is 3separated from the variable list with a colon (:). 



EXAMPLE:



;        10  INPUT PROMPT 'Please enter your name: ': name$ "        20  PRINT 'Hello '; name$         30  END          RNH '        Please enter your name: Jackie         Hello Jackie 
0

5.8 AT Option



?The AT option positions the cursor on the specified row Gand column. This is the position where the INPUT statement starts the (prompt, not where the user enters data. 

FORMAT:



        AT row, col 


@row is the row to print at. col is the column to @print at. row and col can be any integer numeric constants. 



EXAMPLE:



        10  CLEAR             PRINT AT 1, 1: E        20  INPUT AT 3, 10, PROMPT 'Please enter your name: ': name$ "        30  PRINT 'Hello '; name$         40  END          RNH            (row 3, col 10)                  |                  V .                 Please enter your name: Jack         Hello Jack 
8

5.9 ATTRIBUTES Option



;The ATTRIBUTES option allows input with attributes. The available attributes are: 





IMultiple attributes used in one INPUT statement are separated by commas. 

FORMAT:



        ATTRIBUTES attr_list 


6attr_list contains a list of input attributes. 



EXAMPLE:



+        10  name_attr$ = 'BOLD, UNDERLINE' G        20  LINE INPUT 'Enter your name', ATTRIBUTES name_attr$: name$ "        30  PRINT 'Hello '; name$         40  END          RNH ,        Enter your name? Susan        Hello Susan 
6

5.10 LENGTH Option



@The LENGTH option limits the number of characters that a Nuser can enter. It causes INTOUCH to display underscore characters following ?the prompt. The number of underscore characters is the length. 

FORMAT:



        LENGTH num_expr 


@num_expr is the number of characters the user can enter. 



EXAMPLE:



6        10  INPUT 'Enter your name', LENGTH 15: name$ 3        20  INPUT 'Enter a city', LENGTH 20: city$         30  PRINT name$, city$         40  END          RNH )        Enter your name? Betty__________ +        Enter a city? 'San Diego'_________ &        Betty               San Diego 
7

5.11 DEFAULT Option



?DEFAULT lets you provide defaults for INPUT statements. MINTOUCH automatically formats the default appropriately. The user can press 5Return to accept the default you provide. 



FORMAT:



        DEFAULT str_expr 


Istr_expr is a string expression that will be used as the default. GWhen INTOUCH executes an INPUT statement with a default, it prints the default after the prompt. 



EXAMPLE:



?        10  INPUT 'Enter the state code', DEFAULT 'CA': state$ ,        20  PRINT 'The state was: '; state$         30  END          RNH                    !        Enter the state code? CA         The state was: CA 


EIf the user does not want the default, they can simply type over the default text. 

S

5.11.1 Pre-positioning to a DEFAULT Menu Item



8When performing an INPUT MENU, the DEFAULTFoption can be used to specify a default menu path. The default takes the format of: 



        #item1;#item2;... 


;#item1 is the number of the item on the first menu, G#item2 is the number of the item on the second menu, and so on. 

;Upon the completion of a INPUT MENU statement, the concept =_STRING contains the menu path taken by the user when 6selecting the menu item. i.e. #2;#3 means the =3rd item of the 2nd submenu. (For information on menus, see Section 5.17, MENU Option.) 



EXAMPLE:



10  CLEAR 220  line1$ = '%WIDTH 12, %MENUBAR, %AUTOVBAR ON,' 6    line2$ = 'file = {new, get_file, save, save_as},' *    line3$ = 'edit = {cut, copy, paste},' O    line4$ = 'paragraph = {font, alignment, spacing, tabs, headers, footers},' C    line5$ = 'options = {ruler = {on, off}, side_bar = {on, off},' 6    line6$ = 'view = {enlarged, normal, small}},exit' E30  test_menu$ = line1$ + line2$ + line3$ + line4$ + line5$ + line6$     the_default$ = '' 40  DO 8      INPUT MENU test_menu$, DEFAULT the_default$: ans$       IF  _EXIT  THEN  EXIT DO '      MESSAGE 'Menu path was', _STRING       the_default$ = _STRING 	    LOOP 50  END 




Q+------------------------------------------------------------------------------+ X|  FILE      |   EDIT      |   PARAGRAPH   |   OPTIONS   |   EXIT              | Q+--------------------------------------------+---OPTIONS---+-------------------+ @                                             |  RULER    [>| I                                             |  SIDE_BAR +----VIEW-----+ P                                             |  VIEW     |  ENLARGED   | P                                             +-----------|  NORMAL     | I                                                         |  SMALL      | I                                                         +-------------+  :                             Menu path was #4;#3;#2
5

5.12 ERASE Option



AThe ERASE option clears the input line prior to accepting Iinput. After input has been completed, the input line is cleared again. 

        10  CLEAR             PRINT AT 1,1: 9        20  INPUT 'Please enter a name', AT 3,1: name_1$ =            INPUT 'Enter a 2nd name', AT 4,1, ERASE: name_2$ (            PRINT '1st name: '; name_1$ (            PRINT '2nd name: '; name_2$         30  END          RNH #        Please enter a name? James          1st name: James         2nd name: Tony 
5

5.13 VALID Option



>The VALID option validates user responses according to specified validation rules. 



FORMAT:



        VALID str_expr 


1str_expr is the list of validation rules. 

HYou can refer to the VALID() function in Appendix A, Built-in Functions -for information on all the validation rules. 



EXAMPLE:



1        10  INPUT 'Enter name', LENGTH 20: name$ ?        20  INPUT 'Enter age', LENGTH 5, VALID 'INTEGER': age$         30  PRINT name$, age$         40  END          RNH )        Enter name? Aaron_______________         Enter age? 32___         Aaron               32 
7

5.14 TIMEOUT Option



BThe TIMEOUT option limits the time the user has to respond Fto the INPUT prompt. A time limit must be specified with the TIMEOUT Foption. If the user does not complete the INPUT statement within the Gspecified time, an exception ("timeout on input at xx") is generated. 

FORMAT:



        TIMEOUT num_expr 


Fnum_expr is a numeric expression that represents the number of "seconds allowed for the response. 



EXAMPLE:



-        10  INPUT 'Name', TIMEOUT 4.5: name$         20  END          RNH %        Name? Timeout on input at 10          INTOUCH 


DTIMEOUT 30 gives the user approximately 30 seconds to enter a name. DFractions of a second can be indicated by including decimal digits. FTIMEOUT 4.5 gives the user approximately 4.5 seconds to enter a name. 

4

5.15 AREA Option



>The AREA option does input from an area on the screen. 



FORMAT:



;        LINE INPUT AREA top, left, bottom, right: str_expr 
  .    $    #    %  
Top Top row of the area on the screen
Left Left column of the area
Bottom Bottom row of the area
Right Right column of the area


EXAMPLE:



        10  CLEAR -        20  MESSAGE 'Press GOLD/F when done' 0        30  LINE INPUT AREA 5, 10, 8, 60: text$ -        40  PRINT AT 10, 1: 'Rewrapped text' &        50  wt$ = WRAP$(text$, 1, 30)         60  PRINT wt$         70  END          RNH  A                This is an example of wrapped text.  The text is D                wrapping.__________________________________________ D                ___________________________________________________ D                ___________________________________________________          Rewrapped text &        This is an example of wrapped %        text.  The text is wrapping. 


@During a LINE INPUT AREA, the following features are available: 





BWhile you are entering text in an area, you can use the following commands:   )    8    .    (    0    1    #    #    E  
Text To enter text, just type it.
Arrow keys To move around, press UP, DOWN, LEFT, RIGHT
CTRL/HMoves cursor to beginning of line
CTRL/EMoves cursor to end of line
GOLD/BMoves cursor to the top of the area
GOLD/FComplete (finish) and save the input
F10 Exit (abort) the input
CTRL/ZExit (abort) the input
HelpExits from the input and sets the variable _HELP to true


EWhen you finish a LINE INPUT AREA, INTOUCH removes any trailing line feeds and spaces. 

6

5.16 SCREEN Option



@The SCREEN option is used to create formatted data entry Jscreens. The SCREEN option lets the user enter data into a fill-in area. 



FORMAT:



        SCREEN str_expr 


-str_expr specifies the screen format. 



EXAMPLE:



-        10  INPUT 'Your name, please': name$ F        20  INPUT SCREEN 'Soc. sec.: <DIGITS:###-##-####>': SSN 8        30  PRINT name$, 'Social security number:'; SSN         40  END          RNH          Your name, please? John         Soc. sec.: ___-__-____ 


DWhen the program executes, INTOUCH displays the prompt "Soc. sec.:" Band a fill-in area with underscore characters where the user must Afill in a number. The fill-in area is highlighted. As the user Benters the social security number, it appears in the fill-in area Kand the underscores disappear. When the Return key is pressed, 0the number is assigned to the the variable SSN. 

        RNH          Your name, please? John         Soc. sec.: 555-48-6662 ?        John                Social security number: 555486662  


GYou can use the SCREEN option with any data type. A string expression Gfollows the keyword SCREEN. The expression contains any text to print &and the format for the fill-in areas. 

FA number of commands can be used within the format to control how the 5fill-in area works. These fall into two categories: 





EFormat options come first. They are followed by a colon and then by format characters. 

E

5.16.1 Screen Format Characters



#





;The # is used to specify digits. Wherever a J# sign appears, only these types of characters are allowed as input. For 1example, the # might be used for a phone number: 

A        10  INPUT SCREEN '<:(###) ###-####>': phone         20  PRINT phone         30  END 


LWhen INTOUCH executes this program, it displays the following fill-in area: 

        (___) ___-____          RNH         (555) 554-7879         5555547879 


@





9The @ is used to specify any printable character, including letters and numbers. 

H        10  INPUT SCREEN 'License #: <@@@ @@@@>': license$ (        20  PRINT 'License: '; license$         30  END          RNH         License #: INF 5783         License: INF5783 


.





?A decimal point is used to align the fractional portion Tof a floating point number. If the screen format is in the form <###.####>, Owhen the user presses the . key, the digits will be right-justified Kto the decimal point. When the field is complete, the digits to the right )of the decimal will be left-zero filled. 

&        10  PRINT 'Input .59, please' A        20  INPUT SCREEN 'Amount: <###.####>': amt$ $            PRINT 'Amount = '; amt$         30  END          RNH         Input .59, please         Amount = .5900 


^





>The ^ is used to specify an UPPER-CASE letter. If the Gnext character input is a lower-case letter, INTOUCH will change it to 6upper-case and echo it to the terminal in upper-case. 

M        10  INPUT SCREEN 'First name: <^@@@@@@@@@@@@@>': first$ F            INPUT SCREEN 'Middle initial: <^>.': middle$ M            INPUT SCREEN 'Last name: <^@@@@@@@@@@@@@@@>': last$ 4        20  PRINT first$; ' '; middle$; '. '; last$         30  END          RNH $        First name: John___________         Middle initial: B. %        Last name: Smithy___________         John B. Smithy 


~





@The ~ (tilde) is used to specify that any character that $follows the ~ will not be replaced. 



B

5.16.2 Screen Format Options



AIf you use format options, they must be placed before the Iformat characters and followed by a colon. The following format options are available: 



UCASE





MUpper-cases all letters that are typed. If you type a letter in lower-case, Nit is changed to upper-case and echoed to the terminal screen in upper-case. 

'        10  PRINT 'Type in some text!' E        20  INPUT SCREEN '<UCASE:@@@@@@@@@@@@@@@@@@@@>': text$ /        30  PRINT 'Here is your text: '; text$         40  END          RNH         Type in some text!         JOHN B. SMITHY______ *        Here is your text: JOHN B. SMITHY 



LCASE





MLower-cases all letters that are typed. If you type a letter in upper-case, Mit is changed to lower-case and echoed to the terminal screen in lower-case. 

'        10  PRINT 'Type in some text!' M        20  INPUT SCREEN '<LCASE: @@@@@@@@@@@@@@@@@@@@>': text$ /        30  PRINT 'Here is your text: '; text$         40  END          RNH         Type in some text!         john b. smithy *        Here is your text: john b. smithy 



NOECHO





9Typed characters are not echoed (printed) on the screen. 

G        10  INPUT SCREEN '<NOECHO:Password? @@@@@>' : pw$         20  PRINT pw$         30  END          RNH         Password? _____         Elene               



DIGITS





LAllows only digits to be entered in the field. The format character # also -allows the minus sign and the decimal point. 

H        10  INPUT SCREEN 'Phone: <DIGITS:###-####>': phone         20  PRINT phone         30  END          RNH         Phone: 555-6798          5556798 


AJ





AAJ causes INTOUCH to jump automatically to the next field Iwhen the current field has been filled in. The field must be completely 6filled in before INTOUCH will jump to the next field. 

L        10  INPUT SCREEN 'Phone: <AJ, DIGITS:###-####>': phone M        20  INPUT SCREEN 'Soc. sec.: <DIGITS:###-##-####>': ssn         30  PRINT phone, ssn         40  END          RNH         Phone: 555-3839         Soc. sec.: 899-75-3432 &         5553839            899753432 


REQ





?REQ specifies that input is required and you must enter Hsomething. The computer will beep and you will be prompted until valid input is entered. 





AT row, column





=The AT option displays the field on the screen at the Drow and column position specified. row specifies the row to ;print at. column specifies the column to print at. 

IYou can supply defaults for each field in the screen. The format of the Mdefaults is a list of values separated with line feeds. Defaults are set up in the following example. 

        10  city$ = 'St Paul' !            state$ = 'Minnesota' ,            df$ = city$ + chr$(10) + state$             CLEAR T            scr$ = '<AT 6, 10: City @@@@@@@@@@@@@@@@@@@@@@@@@@>' & 9                   +'<AT 7, 10: State  ^^>' :            INPUT SCREEN scr$, DEFAULT df$: city$, state$         20  END          RNH         City     St. Paul         State    Mi 



VALID





=The VALID option allows full validation of each field 4on the screen. (See the VALID function in Appendix ADfor a list of validation rules.) The format of the VALID option is: 

        VALID 'rule_str' 


Grule_str is the list of validation rules. Multiple validation $rules are separated by semi-colons. 

Q        10  INPUT SCREEN 'code = <VALID "integer":###-##-##>': ans$             PRINT ans$         20  END          RNH         code = 121-23-47         1212347 



ELAPSED





?The ELAPSED option keeps track of the time it takes the Muser to respond to an INPUT prompt. INTOUCH assigns the elapsed time to the Ivariable specified. The ELAPSED option starts marking time when INTOUCH Jfinishes displaying the prompt. Time stops when all the variables listed 4in the INPUT statement have values. The format is: 

        ELAPSED num_var 


Inum_var is the numeric variable the elapsed time is assigned to. LINTOUCH returns the elapsed time in seconds. If a real numeric variable is Hspecified, INTOUCH returns the time to a hundredth of a second (1/100). 

2        10  INPUT 'Name', ELAPSED x: name$ 5        20  PRINT name$; ', your elapsed time is'; x         30  END          RNH         Name? John (        John, your elapsed time is 1.39 


DIf an integer variable is specified, INTOUCH rounds the time to the nearest second. 

3        10  INPUT 'Name', ELAPSED x%: name$ 6        20  PRINT name$; ', your elapsed time is'; x%         30  END          RNH         Name? Julie &        Julie, your elapsed time is 1 

(

BOLD, BLINK, UNDERLINE, REVERSE





/The BOLD, BLINK, UNDERLINECand REVERSE options allow each input string to be displayed Mwith its own attributes. If these format options are used together with the <ATTRIBUTES option, the ATTRIBUTES option will be supressed. 

M        10  INPUT SCREEN '<AT 5,10, BOLD,BLINK:@@@@@@>' + & P                         '<AT 6,10, REVERSE:@@@@@@>': str1$, str2$         20  END 

U

5.16.3 The User's Response to the SCREEN Option



IWhen a single INPUT SCREEN statement is used to create a fill-in screen, Icertain keys on the keyboard have special functions. The following keys $can be used to complete the screen: 

%

TAB



4


Next page... | 6Table of Contents