Previous | Contents | Index |
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.
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 ******************************************************************************** ******************************************************************************** **************************************** |
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.
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 |
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.
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 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 |
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.
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 |
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.
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 |