SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

%TITLE ".........."

The %TITLE ".........." directive assigns a title to a menu or submenu.

%WIDTH

The %WIDTH directive controls the minimum width of the current column.

FORMAT:


        %WIDTH number 

EXAMPLE:

Example 8-48 %WIDTH menu directive

  menu$ = '%width 20,%items 2, a, b, c,d, f, g, h, i, j' 
  input menu menu$ : ans$ 
  end
 
        
 
        +------------------------------------------------------------------------------+ 
        |<<  C                 |   F                 |   H                           >>| 
        |    D                 |   G                 |   I                             | 
        +------------------------------------------------------------------------------+ 

%INACTIVE

Normally menus are ON TOP of all windows and ACTIVE. The %INACTIVE directive makes the menus be like "normal" windows where other windows can be on top of them.

FORMAT:


        %INACTIVE 

EXAMPLE:

Example 8-49 %INACTIVE menu directive

  title$ = '%inactive, %title "structure",%multi,' 
  box_loc$ = '%at 10,15,' 
  client$ = '"TTI_Client"={id,name={Cass,Brock,Errant},phone},' 
  address$ = 'address={%bar,street,city,state,country},' 
  misc$ = 'misc={%replace,mail,record}'   
  menu$ = title$ & box_loc$ & client$ & address$ & misc$ 
  line input menu menu$: ans$ 
  end 
  
  
               +---STRUCTURE---+ 
               |  TTI_CLIENT  +---ADDRESS--+ 
               |  ADDRESS     |------------| 
               |  MISC...     |  STREET    | 
               +--------------|  CITY      | 
                              |  STATE     | 
                              |  COUNTRY   | 
                              +------------+ 
 

%NOMOUSEOVER

Usually as you move your mouse over a menu item, the menu item under the mouse becomes active. %NOMOUSEOVER turns off the mouse-over feature.

FORMAT:


        %NOMOUSEOVER 

EXAMPLE:

Example 8-50 %NOMOUSEOVER menu directive

  menu$ ='%nomouseover, OPEN, SHOW, PRINT, %heading "GUIDE_OPTIONS",' + 
     'NOSYSTEM, "MENU ON|OFF"' 
  line input menu menu$ : ans$ 
  end 
  
 
 
        +------------------+ 
        |  OPEN            | 
        |  SHOW            | 
        |  PRINT           | 
        |                  | 
        |  GUIDE_OPTIONS   | 
        |  NOSYSTEM        | 
        |  MENU ON|OFF     | 
        +------------------+ 

8.18.4 User Interface

The following is the user interface in a [LINE] INPUT MENU:

8.19 KEY INPUT

FORMAT:


        KEY INPUT [[#channel] [, PROMPT str_expr] 
             [, TIMEOUT time_limit] 
             [, ELAPSED num_var] 
             :] var, [var,...] 

EXAMPLE:

Example 8-51 KEY INPUT statement

  print 'See how quick you are.' 
  key input prompt 'Press a key, quick!', & 
      elapsed x: press$ 
  print
  print 'You took'; x; 'seconds to Press '; press$; '.' 
  end
 
        
See how quick you are. 
Press a key, quick! 
You took 1.99 seconds to Press h. 

PURPOSE:

KEY INPUT is used to input a keystroke from the user and stores the value of the key in the string variable specified.

DESCRIPTION:

Some applications require the use of special keys or keystroke level validation. The KEY INPUT statement is used for these applications.

KEY INPUT does not echo the key pressed, nor does it generate a line feed.

All the options available with the preceding "INPUT" statement are also available with KEY INPUT. KEY INPUT returns the following:

_back
_exit
_help
_terminator
_TERMINATOR returns control (Ctrl) characters in the format "CTRL/X". For example, if the user presses [Ctrl/G], _TERMINATOR returns "CTRL/G".

Example 8-52 _TERMINATOR system function

  key input 'Press a terminator' : z$ 
  print 
  print 'You pressed '; _terminator
  end
 
        
Press a terminator?            (User presses [CTRL/G]) 
You pressed CTRL/G 


Chapter 9
Input Dialogbox - Creating GUI Forms with SheerPower

9.1 INPUT DIALOGBOX Statement

FORMAT:


        INPUT DIALOGBOX str_exp[, DEFAULT str_exp]: str_var 

EXAMPLE:

Example 9-1 INPUT DIALOGBOX

  form$ = '<form>' 
  form$ = form$ + 'City: <input type=text name=city><br>' 
  form$ = form$ + 'State: <input type=text name=state>' 
  form$ = form$ + '</form>' 
  input dialogbox form$: response$ 
  end

When the program executes, SheerPower displays the "City" field and a fill-in area where the user can fill in a city, followed by the "State" field and a fill-in area where the user can fill in a state. At the bottom of the form, the default form buttons are displayed: SUBMIT, EXIT, HELP and BACK.

PURPOSE:

INPUT DIALOGBOX presents the end user with simple to complex input forms.

DESCRIPTION:

INPUT DIALOGBOX is a very powerful feature of SheerPower. INPUT DIALOGBOX provides the user with the power of HTML forms without using a web browser.

9.2 Parsing Input Dialogbox Results

When the user submits the form, the results entered are returned in the following format:


  fieldname=result 

The fieldname is what the name of each input field is given inside the form code:


  <input type=text name=firstname> 

If there are multiple fieldnames that contain user-entered results, the data is stored into a list separated by a chr$(26):


  fieldname=result chr$(26) fieldname=result chr$(26) fieldname=result 

Below is an example of how to parse the results of a submitted form:

Example 9-2 Parsing Input Dialogbox Results

  myform$ = '<form>City <input type=text name=city  size=40><br>' + 
                  'State <input type=text name=state size=2></form>' 
 
  input dialogbox myform$: ans$ 
 
  for item = 1 to pieces(ans$, chr$(26)) 
    z0$ = piece$(ans$, item, chr$(26)) 
    varname$ = element$(z0$, 1, '=') 
    value$   = element$(z0$, 2, '=') 
    select case varname$ 
    case 'city' 
      print 'City was  : '; value$ 
    case 'state' 
      print 'State was : '; value$ 
    case else
      print 'Unknown: '; varname$ 
    end select
  next item 
  end

Type in a city and state, then click on [SUBMIT]. The results will be printed out to the SP4GL window as seen below:

9.3 Input Dialogbox Directives

There are 3 directives available for use with the Input Dialogbox statement. These directives are used as part of the default option.

The %ERROR directive places the focus on the erroneous field(s) and makes the field text red. Multiple %error directives can be used for multiple errors.

Example 9-3 %ERROR Directive

  test$ = '<form>' 
  test$ = test$ + 'One <input name=one value="1"><br>' 
  test$ = test$ + 'Two <input name=two value="2"><br>' 
  test$ = test$ + 'Three <input name=three value="3"><br>' 
  test$ = test$ + 'Four <input name=four value="4">' 
  test$ = test$ + '</form>' 
  def$ = "%error=one"+chr$(26)+"%error=four"
  input dialogbox test$, default def$: answer$    
  end

The %FOCUS directive allows the focus to be placed on a selected field. Multiple %focus directives can be used if there are multiple fields to move focus to.

Example 9-4 %FOCUS Directive

  test$ = '<form>' 
  test$ = test$ + 'One <input name=one value="1"><br>' 
  test$ = test$ + 'Two <input name=two value="2"><br>' 
  test$ = test$ + 'Three <input name=three value="3"><br>' 
  test$ = test$ + 'Four <input name=four value="4">' 
  test$ = test$ + '</form>' 
  def$ = "%focus=three" 
  input dialogbox test$, default def$: answer$    
  end

The %READONLY directive allows for fields to display data that cannot be changed by the end-user.

To specify multiple fields as "read-only" the chr$(26) separator must be included.

Example 9-5 %READONLY Directive

  test$ = '<form>' 
  test$ = test$ + 'One <input name=one value="1"><br>' 
  test$ = test$ + 'Two <input name=two value="2"><br>' 
  test$ = test$ + 'Three <input name=three value="3"><br>' 
  test$ = test$ + 'Four <input name=four value="4">' 
  test$ = test$ + '</form>' 
  def$ = "%readonly=two"+chr$(26)+"%readonly=four"
  input dialogbox test$, default def$: answer$    
  end


Previous Next Contents Index