Database Solutions - Hints & Tips

Tip 08:
Additional Menu and Browse Entries

1. Introduction

The UNIFACE Development Environment is itself written (at least largely) in UNIFACE. Leaving aside the 'chicken and egg' question, this allows us to customise it and add our own UNIFACE code. In UNIFACE 5 and 6, if we wanted to add our own code we had to replace one of the UNIFACE development forms with our own code, by using an assignment file trick. (see previous tip of the week). UNIFACE Seven allows us the ability to add our own menu options more easily.

tip08_img01.gif (20019 bytes)

2. Create the Menu

To add the menu options create a drop down menu called ADDITIONAL in the library USYS. These menus can contain any of the functionality you would normally include.

In this example, there are 3 menu options, one to perform the version Six browse entries function, one to invoke debug and one to generate the code for a while loop, based on the text under which the cursor is positioned.

tip08_img02.gif (22389 bytes) 

3. Set the Preference

Having created, and compiled the menu, you may need to set the preference that you want to actually use it.

Select: Utilities, Preferences, General

tip08_img03.gif (38688 bytes)

tip08_img04.gif (19758 bytes)

4. UNIFACE Six

In UNIFACE Six, when editing proc code in the trigger editor, a button existed to allow the developer to get a list of entries, in the current trigger. This was particularly useful in the local proc modules trigger.

tip08_img05.gif (25647 bytes)

Figure 5: The Browse Entries button.

tip08_img06.gif (20749 bytes)

When you pressed 'OK' the cursor was repositioned on the highlighted entry.

5. UNIFACE Seven

In UNIFACE Seven, this functionality has been removed! To alleviate this problem, we have created a UNIFACE form, which takes a single parameter, in $1, which is the trigger code. It analyses the code and produces a list of entries.The user can select the entry, by double clicking on the fields, or pressing the OK button. When selected the cursor is repositioned on that entry. The functionality has been enhanced, to not only identify local proc routines, but also UNIFACE Seven operations. Sort functionality is provided, using the header bars, to either sort by name or line number. The repositioning is done using the macro statement to move the cursor down the required number of lines.It relies on the cursor being correctly positioned in the field with the proc code.

tip08_img07.gif (21863 bytes)

6. Installation

If you do not have an existing additional menu:

  1. Import the supplied TRX,
    /imp
    browse.exp

  2. Compile the menu e.g.
    /men usys
    from the command line

  3. Compile the form Browse
    /frm browse
    from the command line

The additional menu should now be available.

If you have an existing additional menu:

  1. Add a menu item
    With the following code in the option trigger:

    call Macro_First_text
    if ($fieldname = "TREE")
    $1 = DummySS.Dummy1
    else
    $1 = @$fieldname
    endif
    run "BROWSE"
    ;-----------
    entry Macro_First_Text
    ;--------------------
    macro "^FIRST_TEXT"


  2. Import the TRX browseform.exp
    /imp browseform.exp


  3. Compile the form
    /frm browse

The additional menu should now be available.

compuware_01.gif (3977 bytes)


Copyright ©2000 OCS Consulting plc

dbs_block_logo.gif (2150 bytes)
Refresh Frames