Re: Sql*Forms (Highlighting Fields / using pointer)
Date: Thu, 10 Jun 1993 19:01:26 GMT
Message-ID: <sjsC8F66E.A3x_at_netcom.com>
Jennifer Farnham (v045100_at_otis1.stortek.com) wrote:
: Hello SQL*FORMS gurus:
: What I want to do is create a menu.
: I would like to use the arrow keys to highlight the choices as I
: move thru them. Now, I know about:
: If anyone has really cool code that they want to share, I would greatly
: appreciate it.
: Thanks,
: Jennifer Farnham
: StorageTek
: Boulder, Colorado
: email to: Jenny_Farnham_at_stortek.com or post here to this newsgroup... :-)
Here is a dialog box form that I set up that can be used as is or modified to work as a full page menu screen. It does a forms-based highlighted menu where the up and down arrows move the virtual cursor.
To use this form...you must call it from another form. If you try to execute it directly, you will get an error message. There is a global variable (:global.title) that must be set by the calling form first. It contains a text string that will be displayed in the dialog box.
After calling the form and then when the dialog form returns control back to the calling form, the global var :global.doi will contain 'YES','NO' or 'CANCEL' to indicate the users response.
So, to call the dialog form, do this........
. . :global.title := 'Do you really wish to Delete?'; call('dialog',NO_HIDE,NO_REPLACE); if :global.doi = 'YES' then /* do junk here */ else /* don't do junk */ end if; . .
Here is the dialog.inp file itself...
Note - see my final notes at the end ...
- cut here -------------------------------------
/* Copyright (c) 1988 by the Oracle Corporation */
SQL*FORMS_VERSION = 03.00.16.04.01
TERSE = ON
DEFINE FORM
COMMENT = <<<
RCS Info: $Source: /section4/gax65a/Source/RCS/dialog.inp,v $ $Header: dialog.inp,v 1.1 93/02/17 10:17:17 gax65a Exp $>>>
NAME = dialog
TITLE = Alert
DEFAULT_MENU_APPLICATION = DEFAULT
DEFINE PROCEDURE
NAME = go_DIALOG DEFINITION = <<< procedure go_DIALOG is begin bell; :global.cur_loc := block_characteristic('DIALOG',FIRST_FIELD); go_field('dummy'); end; >>>
ENDDEFINE PROCEDURE DEFINE PROCEDURE
NAME = de_inverse_field DEFINITION = <<< procedure de_inverse_field(fname in char) is begin if field_characteristic(fname,ENTERABLE) = 'FALSE' then display_field(fname,'bold'); end if; end; >>>
ENDDEFINE PROCEDURE DEFINE PROCEDURE
NAME = de_inverse_block DEFINITION = <<< procedure de_inverse_block(cur_block in char) is cur_field char(80); begin cur_field:=block_characteristic(cur_block,FIRST_FIELD); while cur_field is not null loop cur_field:=cur_block||'.'||cur_field; de_inverse_field(cur_field); cur_field:=field_characteristic(cur_field,NEXTFIELD); end loop; end; >>>
ENDDEFINE PROCEDURE DEFINE PROCEDURE
NAME = nav_DIALOG DEFINITION = <<< procedure nav_DIALOG is begin :global.cur_loc:=field_characteristic(:global.cur_loc,NEXTFIELD); if :global.cur_loc = 'DUMMY' then :global.cur_loc := 'YES'; end if; de_inverse_block('DIALOG'); display_field(:global.cur_loc,'inverse'); end; >>>
ENDDEFINE PROCEDURE DEFINE PROCEDURE
NAME = nav_DIALOG_back DEFINITION = <<< procedure nav_DIALOG_back is begin :global.cur_loc:=field_characteristic(:global.cur_loc,PREVIOUSFIELD); if :global.cur_loc is null then :global.cur_loc := 'CANCEL'; end if; de_inverse_block('DIALOG'); display_field(:global.cur_loc,'inverse'); end; >>>
ENDDEFINE PROCEDURE DEFINE PROCEDURE
NAME = setup DEFINITION = <<< procedure setup is begin de_inverse_block('DIALOG'); display_field('YES','inverse'); go_DIALOG; default_value('Alert',:global.title); if length(:global.title) > 30 then :global.title:=substr(:global.title,1,30); end if; :DIALOG.title := :global.title; message('Use Arrow Keys to Navigate; Return to Select'); end; >>>
ENDDEFINE PROCEDURE DEFINE TRIGGER
NAME = key-down TRIGGER_TYPE = V3 TEXT = <<< nav_DIALOG; message('Use Arrow Keys to Navigate; Return to Select'); >>>
ENDDEFINE TRIGGER DEFINE TRIGGER
NAME = key-exit TRIGGER_TYPE = V3 TEXT = <<< :global.doi := 'CANCEL'; exit_form; >>>
ENDDEFINE TRIGGER DEFINE TRIGGER
NAME = key-nxtfld TRIGGER_TYPE = V3 TEXT = <<< begin :global.doi := :global.cur_loc; /* message('Working...');*/ exit_form; exception when form_trigger_failure then null; end; >>>
ENDDEFINE TRIGGER DEFINE TRIGGER
NAME = key-others TRIGGER_TYPE = V3 TEXT = <<< bell; message('Use Arrow Keys to Navigate; Return to Select'); >>>
ENDDEFINE TRIGGER DEFINE TRIGGER
NAME = key-startup TRIGGER_TYPE = V3 TEXT = <<< setup; >>>
ENDDEFINE TRIGGER DEFINE TRIGGER
NAME = key-up TRIGGER_TYPE = V3 TEXT = <<< nav_DIALOG_back; message('Use Arrow Keys to Navigate; Return to Select'); >>>
ENDDEFINE TRIGGER DEFINE BLOCK
COMMENT = <<< Alert Box >>> NAME = DIALOG DESCRIPTION = Alert IN_MENU = OFF ROWS_DISPLAYED = 1 BASE_LINE = 1 LINES_PER_ROW = 0 ARRAY_SIZE = 0 DEFINE FIELD NAME = yes DATATYPE = CHAR LENGTH = 5 DISPLAY_LENGTH = 5 QUERY_LENGTH = 5 BASE_TABLE = OFF PAGE = 1 LINE = 4 COLUMN = 14 EDIT_WORD_WRAP = OFF DEFAULT = (Yes) INPUT = OFF UPDATE = OFF QUERY = OFF ENDDEFINE FIELD DEFINE FIELD NAME = no DATATYPE = CHAR LENGTH = 4 DISPLAY_LENGTH = 4 QUERY_LENGTH = 4 BASE_TABLE = OFF PAGE = 1 LINE = 6 COLUMN = 14 DEFAULT = (No) INPUT = OFF UPDATE = OFF QUERY = OFF ENDDEFINE FIELD DEFINE FIELD NAME = cancel DATATYPE = CHAR LENGTH = 8 DISPLAY_LENGTH = 8 QUERY_LENGTH = 8 BASE_TABLE = OFF PAGE = 1 LINE = 8 COLUMN = 14 DEFAULT = (Cancel) INPUT = OFF UPDATE = OFF QUERY = OFF ENDDEFINE FIELD DEFINE FIELD NAME = dummy DATATYPE = CHAR LENGTH = 1 DISPLAY_LENGTH = 1 QUERY_LENGTH = 1 BASE_TABLE = OFF PAGE = 1 LINE = 1 COLUMN = 1 ECHO = OFF ENDDEFINE FIELD DEFINE FIELD NAME = title DATATYPE = CHAR LENGTH = 30 DISPLAY_LENGTH = 30 QUERY_LENGTH = 30 BASE_TABLE = OFF PAGE = 1 LINE = 2 COLUMN = 7 INPUT = OFF UPDATE = OFF QUERY = OFF ENDDEFINE FIELD
ENDDEFINE BLOCK DEFINE SCREEN DEFINE PAGE
PAGE = 1 POPUP = ON BORDER = ON DISSOLVE = ON PAGE_XS = 0 PAGE_YS = 0 PAGE_PX0 = 0 PAGE_PY0 = 0 PAGE_PXS = 45 PAGE_PYS = 11 PAGE_SX0 = 12 PAGE_SY0 = 8 ENDDEFINE PAGE
ENDDEFINE SCREEN ENDDEFINE FORM
------------------------ cut here -------------------------------------
The only real disadvantage to this scheme is that each menu item must be represented by a field. A better approach would be data driven, where a table contains rows which represent the menu items and then the logic works to create the menu that way. That is little trickier and I havn't really had time to do it that way yet.
I did do something along those lines with a little arrow pointer that points to the current record in a detail block. Hmmm...maybe I'll look into this a little more. A generic data driven menu form would be pretty cool!!!
If anyone tries to use this and wants help getting it working, just drop me a line and I'll try to help you out.
-- ------------------------------------------------------------------ Steve Schow | But you don't have to use the claw, if you sjs_at_netcom.com | pick the pear with the big paw paw...... (415) 354-4908 | Have I given you a clue......? | - Baloo the Bear ------------------------------------------------------------------Received on Thu Jun 10 1993 - 21:01:26 CEST