SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index


Chapter 8
Data Entry User Interface

This chapter describes the various ways that data can be entered at the pc and stored into variables.

8.1 INPUT Statement

FORMAT:


        [line] input var, var... 
 
        [key] [line] input [  ['Prompt_text'] 
          [, prompt str_expr] [, erase] 
          [, at row, column] [, length num_expr] [, default str_expr] 
          [, VALID str_expr] [, timeout time_limit] [, elapsed num_var] 
          [, area num_expr, num_expr, num_expr, num_expr] [, attributes attr_list] 
          [, screen '[text] <format>...'] 
          [, dialogbox str_exp,] 
          [, menu str_expr: str_var] :] var [,var. . .] 

EXAMPLE:

Example 8-1 INPUT statement

  input 'Please enter your first name': first$ 
  input 'Now, enter your last name': last$ 
  line input 'Where do you live': city$ 
  print
  print 'Hello '; first$; ' '; last$ 
  print 'From '; city$ 
  end
 
        
Please enter your first name? Sunny 
Now, enter your last name? Day 
Where do you live? San Diego, California 
 
Hello Sunny Day 
From San Diego, California 

PURPOSE:

The INPUT statement is used to ask questions from the user and store the answers for use in a program.

DESCRIPTION:

The INPUT statement reads data typed by the user and assigns it to variables. var is a variable that the data is being assigned to. When SheerPower executes an INPUT statement, it prints any prompt given and waits for the user's response. The user's response is then assigned to the variable(s) specified.

For information on INPUT from a text file, see Chapter 14, File Handling.

The user enters data in response to the INPUT statement. The input data must be the same data type as the variable, or SheerPower generates an exception. If, in response to the INPUT statement, the user presses the [Enter] key and:

8.1.1 Types of INPUT Statements

There are three types of INPUT statements:

8.1.2 INPUT Styles

There are four input styles:

  1. Simple input

    Example 8-2 Simple input style

      input 'Please enter your name': name$ 
      print 'Hello '; name$ 
      end
     
            
    Please enter your name? Toby 
    Hello Toby 
    


  2. Formatted data entry screens (see Section 8.17, SCREEN Option)

    Example 8-3 Formatted data entry screens

      input 'Please enter your name': name$ 
      input screen 'Soc. sec.: <DIGITS: ###-##-####>': ssn 
      print name$, 'Social security number:'; ssn 
      end
     
            
    Please enter your name? Fred 
    Soc. sec.:  ___-__-____        (before input) 
    Soc. sec.:  324-11-4533        (after input) 
    Fred                Social security number: 324114533 
    


  3. Free format multi-line text input (see Section 8.15, AREA Option)

    Example 8-4 Free format multi-line text input

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


  4. Pop-up menus (see Section 8.18, MENU Option)

    Example 8-5 Pop-up menus

      sample_menu$ = '%title "Options",' & 
          + 'Add, Change, Delete, Inquire' 
      line input menu sample_menu$: selection$ 
      print 'Menu option was '; selection$ 
      end
     
            
     
              +--Options---+ 
              |  ADD       | 
              |  CHANGE    | 
              |  DELETE    | 
              |  INQUIRE   | 
              +------------+ 
     
            Menu option was CHANGE 
    

8.2 INPUT Options

The INPUT statement has the following options, which are described in detail in following sections of this chapter:

PROMPT displays the prompt text
AT row, col positions the cursor on the desired row and column
LENGTH nn limits the number of characters that a user can type
DEFAULT lets you provide defaults for INPUT statements
VALID validates user responses
TIMEOUT limits the time the user has to respond to the INPUT prompt
AREA does free format multi-line text input from an area on the screen
SCREEN creates formatted data entry screens
MENU displays and receives input from "pop-up" menus
ELAPSED keeps track of the time it takes the user to respond to an INPUT prompt
ATTRIBUTES displays in BOLD, BLINK, REVERSE
ERASE clears the input line prior to accepting input and after the input has been completed
DIALOGBOX presents the end user with simple to complex input forms. See Chapter 9, Input Dialogbox - Creating GUI Forms with SheerPower

8.3 INPUT Commands and Keystrokes Available to the User

At an input prompt, there are several commands and keystrokes that the user can enter instead of an answer to the prompt. These are:

EXIT or [Ctrl/Z]

Type the word EXIT or press [Ctrl/Z] to exit from a prompt or procedure. If one of these options is entered, SheerPower sets the internal variable _EXIT to TRUE (1).

[esc] or UP-arrow

If [esc] or the Up-arrow key is entered, the internal variable _BACK will be set to TRUE (1).

HELP or [Help]

Get help for an input item by typing the word HELP or by pressing the [Help] button in the toolbar. If one of these options is input, SheerPower sets the internal variable _HELP to TRUE (1).

_HELP should be checked before _BACK and/or _EXIT because, in some cases, all three are set on. For example, if "EXIT" is the default and the [Help] key is pressed, both _HELP and _EXIT are set on.

The internal variables _BACK, _EXIT and _HELP can be examined within a program and appropriate action can be taken.

8.3.1 Editing Input

The following keys allow the user to edit input:

Left-arrow move left
Right-arrow move right
Delete key delete character(s) to the left of the cursor
TAB move to next input field or terminate input
[CTRL/A] toggle between insert and overstrike mode
[CTRL/E] move to end of line
[CTRL/H] move to beginning of line
[CTRL/J] delete the word to the left of the cursor.
[CTRL/U] delete all the characters on a line.
[Enter] terminate the input; [Enter] can be pressed anywhere in the line, not only at the end of the line.

8.4 Inputting Strings

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

If the user enters a quoted string, SheerPower removes the quotes, and includes any leading or trailing spaces and tabs.

Example 8-6 Inputting Strings

  input 'Enter your name': name1$ 
  input 'Enter your name in quotes': name2$ 
  input 'Enter your name in quotes with spaces': name3$ 
  input 'Enter last name, comma, space, first name in quotes': name4$ 
  print
  print name1$ 
  print name2$ 
  print name3$ 
  print name4$ 
  end
 
 
Enter your name? Tony 
Enter your name in quotes? 'Tony' 
Enter your name in quotes with spaces? '  Tony  ' 
Enter last name, comma, space, first name in quotes? 'Smith, Tony' 
 
Tony 
Tony 
  Tony 
Smith, Tony 


Previous Next Contents Index