INTOUCH® 4GL
Application Development Guide


Previous Contents Index

1.3.2 Other ASK/SET WINDOW Statements

The above examples are only two options of the ASK/SET WINDOW statements. There are many other options available and each of the options is explained in detail in the INTOUCH - A Guide to the Language manual.

1.4 Formatting the Screen

Controlling margins and print zones is very significant in formatting screen data.

1.4.1 Setting the Margin

INTOUCH allows you to control margins with the ASK MARGIN and SET MARGIN statements. By default, margins are set to 80 and the device or channel is #0, the screen terminal.

Example

This example shows how to find the margin, set it to something else and set it back to the current margin.


        1   program application_1_6 
        10  clear 
            print repeat$('*', 200) 
            print 
        20  ask margin current_margin
            print 'The current margin is:'; current_margin 
            input 'What do you want the new margin to be set to'; new_margin 
        30  print 
            print 'The new margin is:'; new_margin 
            print 
            set margin new_margin
            print repeat$('*', 200) 
        40  set margin current_margin
            print 
            print 'The margin has been reset to the original value' 
            print 
            print repeat$('*', 200) 
        50  end 



******************************************************************************** 
******************************************************************************** 
**************************************** 
 
The current margin is: 80 
What do you want the new margin to be set to? 50 
 
The new margin is: 50 
 
************************************************** 
************************************************** 
************************************************** 
************************************************** 
 
The margin has been reset to the original value 
 
******************************************************************************** 
******************************************************************************** 
**************************************** 

1.4.2 Setting Print Zones

The comma separator in the PRINT statement splits data into columns of width determined by the value of ZONEWIDTH. This parameter is useful when formatting data to the screen or to files. The default ZONEWIDTH for all channels is 20 and the default channel is #0, the screen terminal.

INTOUCH gives you control of the device or channel ZONEWIDTHs with the ASK ZONEWIDTH and SET ZONEWIDTH statements.

Example

This example shows how to find the zone width, set it to something else and set it back to the current zone width.


        1   program application_1_7 
        10  clear 
            ask zonewidth current_zonewidth
            print 'ZONE-1', 'ZONE-2', 'ZONE-3', 'ZONE-4', 'ZONE-5', 'ZONE-6', 'ZONE-7' 
            print 
            print 'The current zone width is:'; current_zonewidth 
        20  input 'What would you like to set the new zone width to'; new_zonewidth 
            print 
        30  print 'The new zone width is:'; new_zonewidth 
            print 
            set zonewidth new_zonewidth
            print 'ZONE-1', 'ZONE-2', 'ZONE-3', 'ZONE-4', 'ZONE-5', 'ZONE-6', 'ZONE-7' 
        40  print 
            print 'The zone width is restored to the original value' 
            print 
            set zonewidth current_zonewidth
            print 'ZONE-1', 'ZONE-2', 'ZONE-3', 'ZONE-4', 'ZONE-5', 'ZONE-6', 'ZONE-7' 
        50  end 



ZONE-1              ZONE-2              ZONE-3              ZONE-4 
ZONE-5              ZONE-6              ZONE_7 
 
The current zone width is: 20 
What would you like to set the new zone width to? 10 
 
The new zone width is: 10 
 
ZONE-1    ZONE-2    ZONE-3    ZONE-4    ZONE-5    ZONE-6    ZONE_7 
 
The zone width will be restored to the original value 
 
ZONE-1              ZONE-2              ZONE-3              ZONE-4 
ZONE-5              ZONE-6              ZONE_7 


Chapter 2
Customizing User Input

INTOUCH offers a variety of methods to prompt for and accept input from the user. These methods can be used alone or in combination with others depending on how the user is to be addressed.

The sections that follow give some examples of how INTOUCH can be used to accept and control user input.

2.1 Input Options

There are many options for the INPUT statement which can be used to customize user input. We will now explore some common input methods offered as options to the INPUT statement. With these options you can do such things as change the input prompt, position the input, set default values, validate the input and return timing statistics.

Example

The following example shows and describes some forms of the INPUT statement.


        1   program application_2_1 
        10  clear 
            print at 1, 1:; 
            input '1 - What is your favorite month' : answer$ 
            line input '2 - What are your favorite animals' : answer$ 
            input prompt '3 - My favorite car is a ' : answer$ 
            input '4 - My favorite season of the year is ', at 5, 1 : answer$ 
            input '5 - Do you like snakes (Yes/No)', default 'No' : answer$ 
            input '6 - What is the date today (MMDDYY)', valid 'date MDY' : answer$ 
            input '7 - This month has how many days', & 
                            valid 'number; allow 28 to 31' : answer 
            print 
            print '8 - You have 10 seconds to answer this question.' 
            input '    What is the 4th letter of the alphabet', timeout 10 : answer$ 
            print 
            print '9 - Answer this question as fast as you can.' 
            input '    What day is today (Monday, Tuesday, etc.)', elapsed x : answer$ 
            print '    It took you'; x; 'seconds to type '; answer$ 
        40  end 



(1) - What is your favorite month? September 
 
(2) - What are your favorite animals? dogs, cats, horses 
 
(3) - My favorite car is a porsche 
 
(4) - My favorite season of the year is ? spring 
 
(5) - Do you like snakes (Yes/No)? No 
 
(6) - What is the date today (MMDDYY)? 041296 
 
(7) - This month has how many days? 30 
 
(8) - You have 10 seconds to answer this question. 
    What is the 4th letter of the alphabet? d 
 
(9) - Answer this question as fast as you can. 
    What day is today (Monday, Tuesday, etc.)? tuesday 
    It took you 3.81 seconds to type tuesday 

  1. Using TEXT to instruct the user
    You can use text to tell the user what to enter. INTOUCH prints your text followed by a ? and a space. This is one of the most common ways to ask for an input item.
  2. Enter a line of data
    You can use the LINE INPUT command if what is to be entered is a line of data, an address for example.
  3. Use the PROMPT option to eliminate the ?
    If you do not want a ? to print, you can use the PROMPT option. If you do not want any prompt at all, use the PROMPT option with a null string (empty quotes).
  4. Use the AT option to position input on the screen
    If you need to place the input at a specific area of the screen, you can use the AT option followed by the row and column. This is useful for columns of data. With the INTOUCH frame ON, there are 21 available rows and 80 columns (132 if wide). Without the INTOUCH frame, there are 24 rows.
  5. Use the DEFAULT option to provide the data
    If the same data is being input over and over again, you can use the DEFAULT option to provide the data. This speeds up data entry and allows the user to override the default to enter other data when necessary. Another benefit is that the defaults can keep data fields from being null values.
    Either a string expression or string variable can be used for the default value.
  6. Use the VALID option to validate input data
    There are often times when the input data needs to be validated. Dates are a good example. You might want the date entered as month-day-year or year-month-day and, of course, you want a valid date. INTOUCH will allow you to specify date formats and also will validate the input data as a valid date.
    Using the VALID option allows you to validate not only dates but also data types (i.e. number, integer), acceptable input data items (a list of possible answers), etc. You can select one or more of the rules that are listed in the appendix section "Built-in Functions" of the INTOUCH - A Guide to the Language manual. INTOUCH will only allow input data which satisfies the validation rule(s) and will display an error message if invalid data is entered.
    Here is an example which validates numbers:


                1   program application_2_2 
                10  clear 
                    print at 1, 1:; 
                20  input prompt 'Enter a screen row number: ', length 2, & 
                        valid 'number; allow 1 to 21' : y 
                30  input prompt 'Enter a screen column number: ', length 2, & 
                        valid 'number; allow 1 to 80' : x 
                40  print at y, x, bold : 'X marks the spot' 
                50  end 
    


    
     Enter a screen row number: 9 
     Enter a screen column number: 50 
     
     
     
     
     
     
                                                     X marks the spot 
    

    The NUMBER validation rule is used in the above example. It is further qualified with a range, as indicated by the ALLOW clause.

  7. Use the TIMEOUT option to limit response time
    Setting a specified response time keeps an application from getting stuck on one line of input code. The TIMEOUT option is used to set the response time. The time limit is a real number interpreted in seconds. If the specified number of seconds pass without any data entry, INTOUCH displays the error message, Timeout at line nn, and generates an exception.
  8. Use the ELAPSED option to determine response time
    There might be instances when you need to determine the user's response time. The ELAPSED option can be used to tell how long a user takes to enter a data item. The clock starts running after the input prompt has been displayed on the screen and stops when all of the input variables have values.
    This option is especially useful for applications such as a typing tutorial.

2.2 Using Fill-in Fields

There are other ways to input data which assist the user and also provide some input error control. Fill-in fields can be used to show the user what data to input and also cut down on input keystrokes. Users are partial to the type of input which appeals to the eye and involves little effort on their part.

INTOUCH offers two INPUT options to create fill-in fields---the LENGTH and the SCREEN options. The LENGTH option displays the length of the input field. The SCREEN option offers other formatting capabilities.

Example

The following example shows some fill-in formats.


        1   program application_2_3 
        10  clear 
            print at 1, 1:; 
        20  attr$ = 'BOLD' 
            input prompt '1 - The current year is ', attributes attr$, length 4 : answer$ 
            print 
        30  ask paint old_paint_char$ 
            set paint '*' 
            input prompt '2 - Next year will be ', length 4 : answer$ 
            print 
        40  set paint old_paint_char$ 
            input screen '3 - Social Security No.: <aj, digits:###-##-####>' : ss_number 
            print 
        50  set paint ' ' 
            input screen '4 - Password: <ucase, req, noecho:@@@@@@@@@@@>' : answer$ 
            print '    Your password was '; answer$ 
        60  set paint old_paint_char$ 
        70  end 



(1) - The current year is ____ 
 
(2) - Next year will be **** 
 
(3) - Social Security No.: ___-__-____ 
 
(4) - Password: 
     Your password was PANDA 

  1. Use the LENGTH option to control input length
    The LENGTH option controls how many characters or digits can be entered by displaying the length of the input with the paint character "_". As a character or digit is entered, the paint character is wiped out. INTOUCH will beep if the user attempts to type in more than the specified amount of paint characters.
    The input data is further enhanced by using the ATTRIBUTES option. This caused the input to be shown as bold characters and distinguishes the input data from from the background data.
  2. Controlling the PAINT character
    INTOUCH allows you to control the paint character, the "_" character, with the ASK PAINT and SET PAINT statements. The default paint character is the underscore. The ASK PAINT statement will tell you what the current paint character is. To change the paint character from the current value, use the SET PAINT statement. You can set the paint character to whatever you want it to be. In example #1, the paint character was "_" and in #2, it was changed to "*".
  3. Use the SCREEN option to format the input
    If you want to do more field formatting (i.e. digits, upper case, etc.), you can use the SCREEN option. This allows you to simulate fill-in fields by providing screen masks. The data can also be filtered using screen format options (i.e. UCASE, LCASE, NOECHO, DIGITS, AJ, REQ, AT) and/or screen format characters (i.e. #, @, ., ^). For details on each screen format option and format character, please refer to the INPUT chapter in the INTOUCH - A Guide to the Language manual.
    Example #3 uses a screen mask for the social security number, allows only digits and automatically jumps to the next prompt.
  4. Example #4 uses upper case to convert lower case to upper case, requires the user to input some data and the noecho suppresses the printing of the input to the screen. The @ specifies any printable character. This is a good example for applications involving passwords.

2.3 Using Free Formatted Areas

Some applications input data that is informative text (a block of text) or perhaps descriptive of another data field. For example, you might want the user to enter some general information about a customer.

INTOUCH offers a free form type of data entry field which is used with the AREA option of the INPUT statement.

The AREA option allows the INPUT statement to accept multiple lines of text, as defined by the upper left and lower right coordinates of a rectangular area.

You can also change the rectangular block size using the INTOUCH WRAP$() function. This allows you to resize blocks of text.

Example

The following example shows how to input a block of text and then to resize the text block. The user types in data for the length of the paint character string. INTOUCH automatically goes to the next line when the previous line is full.


        1   program application_2_4 
        10  clear 
            message 'Press GOLD/F when done' 
        20  line input area 5, 1, 8, 50: text$
            print at 11, 1: & 
                'The text has been resized from 50 to 30 character lines' 
            print 
        30  resized_text$ = wrap$(text$, 1, 30)
            print at 14, 1: resized_text$ 
        40  end 

?15pc The user is presented with the painted input area:



  ___________________________________________________ 
  ___________________________________________________ 
  ___________________________________________________ 
  ___________________________________________________ 
 
 
 
 
 
 
                             Press GOLD/F when done 

?20pc The text is entered and the user presses GOLD/F:



  This customer has a home by the beach.  He likes _ 
  to swim, fish and surf.  He has a boat and often _ 
  takes it out on family trips._____________________ 
  __________________________________________________ 
 
 
  The text has been resized from 50 to 30 character lines 
 
 
  This customer has a home by 
  the beach.  He likes to swim, 
  fish and surf.  He has a boat 
  and often takes it out on 
  family trips. 


Previous Next Contents Index