ZDebug - Forms Debugging Message Tool

ZDebug is a form to help you easily create and display messages from within a form you are debugging.  It also displays DBMS_Output messages created from database pl/sql operations.  ZDebug can be used in any version of Web Forms, as well as Client/Server Forms 6i.

ZDebug.fmb collects and displays your messages within a Forms window.  It is normally called from a form you are testing.  To use it from within any form, all you need to do is copy two objects from ZDebug into your form:  Procedure AA and the Debug pushbutton.

The Zdebug process stores messages you create from program units in your form in a dynamically created record group so they can be displayed in a window when you want.  Optionally, it can also write them to the screen immediately as they are issued.

This tool makes it simple to view messages from a form and from database triggers and packages, so developing and testing complex Forms and server-side processes is easier.
 

Downloading ZDebug

Download ZDEBUG.fmb  (100kb)

Download zdebug.zip  (34kb) Compressed file, contains ZDEBUG.fmb, and this documentation in both html and Richtext format.
 

Questions, Answers and Discussion

If reading all the text below leaves you with questions, please log into the Oracle Forms user forum, and post a message.  That is the best place to get answers.  A topic within the forum has been started at:  http://forums.oracle.com/forums/thread.jspa?threadID=382867
 

Setting up a form to use ZDebug

1.  Open ZDebug.fmb and compile it, creating ZDebug.fmx.  (This only needs to be done once.  Note that the actual file name is all capitals, ZDEBUG.fmx, which is important on case-sensitive operating systems such as Unix.)

2.  Open ZDebug.fmb and copy the AA procedure into your form.  You can also find these setup instructions in comments within the AA procedure.

3.  Copy the Debug pushbutton from block B1 into your form, preferably into a control block.  It normally displays on Canvas1.  Make sure it is placed on the primary content canvas of your form.

Note:  The Coordinate System property in ZDebug is Real, Pixel.  This property is found in the form-level property palette under the "Physical" group.  If you use a different coordinate system, you may need to change ZDebug to use the same as yours, and then save the fmb.  Otherwise, when you copy the Debug pushbutton to your form, its size may be changed drastically.

4.  Create pl/sql calls to the AA procedure in your form that you want to see during the runform session.  For example, you might include this in a post-query trigger:

    AA('Post-Query start, Block='||:system.trigger_block
       ||', Record='||:System.trigger_record
       ||', Hello, etc.');

5.  Compile and run your form.

6.  Turn debug-message mode on with Shift (or Alt-) click on the Debug button.  (The next section describes all the actions available on the Debug button.)

7.  Execute the steps you are testing.  If you used Alt-click on the Debug button, your Form messages will appear as they are issued.  If you used Shift- (or Ctrl-) click to turn on debugging (or are testing with server-side dbms_output messages), use the next step.

8.  View the output messages on the ZDebug screen by Ctrl-Shift-Click on the Debug button.  After viewing, use the "Clear debug msgs" button, then the "Close window" button.  Repeat these last two steps (7 & 8) as often as you need.

9.  After you have completed testing, remove the debugging code:  Delete the AA procedure and the Debug button, then recompile your form.  If you left any messages (calls to the AA procedure), they will become apparent, since they will no longer compile.  …or just do a program search for 'AA' to find all the calls.
 

Running a form and using ZDebug - Clicking the Debug button

When running a form, it normally starts with debugging off.  When you click the Debug button, it performs different actions based on which or how many shift keys you hold down when you click it.  The shift keys are Ctrl, Alt and Shift.  The following are the different actions:

Click with no shift key - A status line message gives you help on using the button, and reports the current setting of Msg_Flag: Y=message recording on, N=off, or I=Immediate messaging.

Click with one shift key (except Alt) - Toggles debugging mode on or off.  A status line message reports the resulting status (On or Off).  DBMS_Output message recording is set on or off to match. Click with Alt key - Turns on debugging mode with Immediate messaging.  Messages are stored in memory, AND are displayed in a pop-up box as soon as they are issued.

Click with two keys - Calls the ZDebug form to display all the messages stored in memory.  If there are none to display, ZDebug is not called and you get a status line message instead.

Click with all three keys - Clears all messages from memory and from the DBMS_Output buffer, without displaying them.
 

Using ZDebug

If you like, you can run ZDebug as a standalone form, to see how it works.  It has the following buttons:

Close window - terminates the form.  If ZDebug was called from another form, control passes back to that form.  If running standalone, it will terminate the runform session.

Clear debug msgs -- clears the screen of all messages and deletes all stored messages from the record group.  This also clears all messages from the DBMS_Output buffer on the server, even if they have not been displayed.  Displays the message: "No messages to display".

Set Msg flag ON (or OFF) - Clicking this button toggles the internal Msg_Flag between values of Y and N, except when Alt-click is used.  This sets Msg_Flag to "I", so messages are displayed on the screen as soon as they are issued.

Add a message - Creates a test message and displays it in the output message area.
 

Limitations

ZDebug can handle a total message character count of up to 32k characters, the limit that can be displayed in a single field.  The single-field display is used so you can copy all the messages for use in other applications (emailing, printing, etc).  You will see an alert message if all messages cannot be displayed.

If you are using a form to test a database package:  If you encounter the message, "ORA-04068: existing state of packages has been discarded" after recompiling a package you are testing, this will stop the DBMS_Output process from recording messages.  Before continuing, you should toggle message-recording mode off and then back on (Ctrl-click twice on the debug button.)

The Oracle DBMS_Output package stores its messages internally within the package.  When you switch off message recording within this process, it also makes a DBMS_Output.Disable call to stop recording.  Doing this causes DBMS_Output to erase all its stored messages.  So simply toggling message recording off then back on erases any DBMS_Output messages.  If you want to see the messages, you must display them first by viewing the ZDebug display window.
 

Miscellaneous

A version log is contained within the ZDEBUG.fmb form, within the form-level comments property.  Additional information on using ZDEBUG is contained within the form in the AA_README form-level trigger.  At the end of that trigger, there is a simple user-guide text.  The AA procedure also contains notes on its use.

A new form can be started from ZDebug, by typing the name of the form name in the message area first line, pressing Enter (to clear other text from the line), then press F8 (Execute Query).  This can be useful if you first start ZDebug to turn message recording on, then need to run your form to test.

If you are using Web Forms, It is best to use ZDebug outside the browser window, since there is more space available to display messages.  Note that you can increase the height and width of the ZDebug screen when displaying messages.  To use any form outside the browser window, just add the following parameter to the end of the URL line used to start Forms:  SeparateFrame=True

Steve Cosner home page.