SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

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$ 
  end
 
        
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.

FORMAT:


        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:

Example 8-18 VALID option

  input 'Enter name', length 20: name$ 
  input 'Enter age', length 5, valid 'integer': age$ 
  print name$, age$ 
  end
 
        
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.

FORMAT:


        TIMEOUT num_expr 

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

EXAMPLE:

Example 8-19 TIMEOUT option

  input 'Name', timeout 4.5: name$ 
  end
 
        
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.

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:

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$ 
  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. 

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.).

8.16 INPUT DIALOGBOX Option

INPUT DIALOGBOX provides the user with all the power of HTML forms without using a web browser. For a complete discussion of INPUT DIALOGBOX please see Chapter 9.

FORMAT:


        INPUT DIALOGBOX str_exp: str_var 

str_expr specifies the dialogbox format.

8.17 SCREEN Option

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

FORMAT:


        SCREEN str_expr 

str_expr specifies the screen format.

EXAMPLE:

Example 8-21 SCREEN option

  input 'Your name, please': name$ 
  input screen 'Soc. sec.: <DIGITS:###-##-####>': SSN 
  print name$, 'Social security number:'; SSN 
  end
 
        
Your name, please? John 
Soc. sec.: ___-__-____ 

When the program executes, SheerPower displays the prompt "Soc. sec.:" and a fill-in area with underscore characters where the user must fill in a number. The fill-in area is highlighted. As the user enters the social security number, it appears in the fill-in area and the underscores disappear. When the [Enter] key is pressed, the number is assigned to the variable SSN.


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

The SCREEN option can be used with any data type. A string expression follows the keyword SCREEN. The expression contains any text to print and the format for the fill-in areas.

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

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

8.17.1 Screen Format Characters

#

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

Example 8-22 Screen format characters -#

  input screen '<:(###) ###-####>': phone 
  print phone 
  end

When SheerPower executes this program, it displays the following fill-in area:


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

@

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

Example 8-23 Screen format characters -@

  input screen 'License #: <@@@ @@@@>': license$ 
  print 'License: '; license$ 
  end
 
        
License #: INF 5783          <-------- type in a license number 
License: INF5783 

.

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

Example 8-24 Screen format characters - .

  print 'Input .59, please' 
  input screen 'Amount: <###.####>': amt$ 
  print 'Amount = '; amt$ 
  end
 
        
Amount:    .         <------ type in .59 here 
Amount = .5900 

^

The ^ is used to specify an UPPERCASE letter. If the next character inputted is a lowercase letter, SheerPower will change it to uppercase.

Example 8-25 Screen Format Characters -^

  input screen 'First name: <^@@@@@@@@@@@@@>': first$ 
  input screen 'Middle initial: <^>.': middle$ 
  input screen 'Last name: <^@@@@@@@@@@@@@@@>': last$ 
  print first$; ' '; middle$; '. '; last$ 
  end
 
 
First name: John___________          <-------- type in john 
Middle initial: B.                   <-------- type in b. 
Last name: Smithy___________         <-------- type in smithy 
John B. Smithy 

Example 8-26 Screen Format Characters - ~

  input screen 'Comparison: <### ~> ###>': a$ 
  print a$ 
  end 
 
 
 


Previous Next Contents Index