A Guide to the Sheerpower Language

Previous Contents Index


        ATTRIBUTES attr_list 

attr_list contains a list of input attributes.


Example 8-13 ATTRIBUTES Option

  name_attr$ = 'bold, blink' 
  line input 'Enter your name', attributes name_attr$: name$ 
  print 'Hello '; name$ 
Enter your name? Susan
Hello Susan 

8.10 LENGTH Option

The LENGTH option limits the number of characters that a user can enter. It causes Sheerpower to display underscore characters following the prompt. The number of underscore characters is the length.


        LENGTH num_expr 

num_expr is the number of characters the user can enter.


Example 8-14 LENGTH Option

  input 'Enter your name', length 15: name$ 
  input 'Enter a city', length 20: city$ 
  print name$, city$ 
Enter your name? Betty__________ 
Enter a city? 'San Diego'_________ 
Betty               San Diego 

8.11 DEFAULT Option

DEFAULT lets you provide defaults for INPUT statements. Sheerpower automatically formats the default appropriately. The user can press [Enter] to accept the default you provide.


        DEFAULT str_expr 

str_expr is a string expression that will be used as the default. When Sheerpower executes an INPUT statement with a default, it prints the default after the prompt.


Example 8-15 DEFAULT option

  input 'Enter the state code', default 'CA': state$ 
  print 'The state was: '; state$ 
Enter the state code? CA 
The state was: CA 

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

8.11.1 Pre-positioning to a DEFAULT Menu Item

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


#item1 is the number of the item on the first menu, #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 selecting the menu item; i.e., #2;#3 means the 3rd item of the 2nd submenu. (For information on menus, see Section 8.18, MENU Option.)


Example 8-16 _STRING System Function

  line1$ = '%width 12, %menubar,' 
  line2$ = 'file = {new, get_file, save, save_as},' 
  line3$ = 'edit = {cut, copy, paste},' 
  line4$ = 'paragraph = {font, alignment, spacing, tabs, headers, footers},' 
  line5$ = 'options = {ruler = {on, off}, side_bar = {on, off},' 
  line6$ = 'view = {enlarged, normal, small}},exit' 
  test_menu$ = line1$ + line2$ + line3$ + line4$ + line5$ + line6$ 
  the_default$ = '' 
    input menu test_menu$, default the_default$: ans$ 
    if  _exit  then  exit do
    message 'Menu path was', _string
    the_default$ = _string
|  FILE      |   EDIT      |   PARAGRAPH   |   OPTIONS   |   EXIT              | 
                                             |  RULER    [>| 
                                             |  SIDE_BAR +----VIEW-----+ 
                                             |  VIEW     |  ENLARGED   | 
                                             +-----------|  NORMAL     | 
                                                         |  SMALL      | 
The menu path was:  #4;#3;#2                                                                                                                  

8.12 ERASE Option

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

Example 8-17 ERASE Option

  print at 1,1: 
  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$ 
Please enter a name? James 
1st name: James 
2nd name: Tony 

8.13 VALID Option

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


        VALID str_expr 

str_expr is the list of validation rules.

Refer to Section 6.6.6, VALID(text_str, rule_str) for information on all the validation rules.


Example 8-18 VALID Option

  input 'Enter name', length 20: name$ 
  input 'Enter age', length 5, valid 'integer': age$ 
  print name$, age$ 
Enter name? Aaron_______________ 
Enter age? 32___ 
Aaron               32 

8.14 TIMEOUT Option

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


        TIMEOUT num_expr 

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


Example 8-19 TIMEOUT Option

  input 'Name', timeout 4.5: name$ 
Name? Timeout on input at 10 

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

8.15 AREA Option

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


        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 8-20 AREA Option

  line input area 5, 10, 8, 60: text$ 
  print at 10, 1: 'Rewrapped text' 
  wt$ = wrap$(text$, 1, 30) 
  print wt$ 
        This is an example of wrapped text.  The text is 
Rewrapped text 
This is an example of wrapped 
text.  The text is wrapping. 

A BELL is outputted if user-entered text goes outside the area.

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

While you are entering text in an area, you can use the following commands:

Text To enter text, just type it
Arrow keys To move around, press UP, DOWN, LEFT, RIGHT
[CTRL/H] Moves cursor to beginning of line
[CTRL/E] Moves cursor to end of line
[esc] Exit (abort) the input
[Help] Exits from the input and sets the variable _HELP to true

The "escape" [esc] keystroke has meaning if it is in the first position of the area (top left corner).

When a LINE INPUT AREA is completed, Sheerpower removes any trailing line feeds and spaces.

Field Size Limit

Because of line breaks, etc. it is possible to reach the field size limit before reaching the fill-in limit. A BELL is outputted when you have entered TOTAL characters that reach the field size (including line separators, etc.).

Previous Next Contents Index