Debugging under CUI

mooringc

New Member
One thing I dislike about PROGRESS is the ability to debug, step through and/or trace running programs under the CUI if you are using unix. The debug option is still displayed on the procedure editors menu, but I cannot access it. On PROGRESS courses I was told it was due to the fact that Motif was no longer supported. I was also told that the main way people debug is by entering countless numbers of display statements to keep track of where your code gets to. I find this time consuming and troublesome. Does anyone out there debug programs ? If so, how ?

Also, is there anyway to view the data in a database, without writing seperate browser programs, if you have a run-time only license ?
 

Chris Kelleher

Administrator
Staff member
Dubugging a complex Progress application has always been a "challenge". Since you are developing ChUI on Unix, the only way to use the debugger would be to get a ProVision license (if you don't already have one) for Win 98/NT. You could then run your unix Progress code using the character client provided in Windows and also use the Debugger tool.

The easier way, which I often do in both Unix and Windows, is to use something like:

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
&GLOBAL-DEFINE Debug

DEF VAR i AS INT INIT 5.

&IF DEFINED(Debug) &THEN
MESSAGE i VIEW-AS ALERT-BOX INFORMATION.
&ENDIF
[/code]

This way you can turn all the debugging messages on/off with one line of code. Using the &IF will also only compile the statements in while debugging, so the deployed r-code doesn't have that overhead in it.

About viewing data (I am assuming from different tables/fields), there is no easy way to do that prior to V9. If you are running version 9 or higher, you can use dynamic queries and browsers to let the user select which tables, where clause, fields to display, etc. If you would like an example of this, please feel free to let me know.

Hope this helps.

-Chris
 

mooringc

New Member
I would love an example of dynamic queries and browsers please. Currently we have written our own browser programs which work OK but I would like to see what other people are doing.

Regards,
Chris
 

Chris Kelleher

Administrator
Staff member
Hi Chris-

Here is an example for using a dynamic query, which will work with the sports database:

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
&ANALYZE-SUSPEND _VERSION-NUMBER AB_v9r12 GUI ADM2
&ANALYZE-RESUME
&Scoped-define WINDOW-NAME wWin
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS wWin
/*------------------------------------------------------------------------

File:

Description: from cntnrwin.w - ADM SmartWindow Template

Input Parameters:
<none>

Output Parameters:
<none>

History: New V9 Version - January 15, 1998

------------------------------------------------------------------------*/
/* This .W file was created with the Progress AB. */
/*----------------------------------------------------------------------*/

/* Create an unnamed pool to store all the widgets created
by this procedure. This is a good default which assures
that this procedure's triggers and internal procedures
will execute in this procedure's storage, and that proper
cleanup will occur on deletion of the procedure. */

CREATE WIDGET-POOL.

/* *************************** Definitions ************************** */

/* Parameters Definitions --- */

/* Local Variable Definitions --- */
DEF VAR qh AS HANDLE NO-UNDO.
DEF VAR bh AS HANDLE NO-UNDO.
DEF VAR fh AS HANDLE NO-UNDO .
DEF VAR x AS INTEGER NO-UNDO.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK

/* ******************** Preprocessor Definitions ******************** */

&Scoped-define PROCEDURE-TYPE SmartWindow
&Scoped-define DB-AWARE no

&Scoped-define ADM-CONTAINER WINDOW

/* Name of first Frame and/or Browse and/or first Query */
&Scoped-define FRAME-NAME fMain

/* Standard List Definitions */
&Scoped-Define ENABLED-OBJECTS Selecttable Selectfld Selectfld2 btnopenqry ~
Btnadd Btnremove EDITOR-1 Btnfirst btnnext btnprev btnlast IMAGE-1
&Scoped-Define DISPLAYED-OBJECTS Selecttable Selectfld Selectfld2 EDITOR-1

/* Custom List Definitions */
/* List-1,List-2,List-3,List-4,List-5,List-6 */

/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME

/* *********************** Control Definitions ********************** */

/* Define the widget handle for the window */
DEFINE VAR wWin AS WIDGET-HANDLE NO-UNDO.

/* Definitions of the field level widgets */
DEFINE BUTTON Btnadd
LABEL ">"
SIZE 6 BY 1.14.

DEFINE BUTTON Btnfirst
LABEL "&First"
SIZE 15 BY 1.14.

DEFINE BUTTON btnlast
LABEL "&Last"
SIZE 15 BY 1.14.

DEFINE BUTTON btnnext
LABEL "&Next"
SIZE 15 BY 1.14.

DEFINE BUTTON btnopenqry
LABEL "Open Query"
SIZE 17 BY 1.14.

DEFINE BUTTON btnprev
LABEL "&Prev"
SIZE 15 BY 1.14.

DEFINE BUTTON Btnremove
LABEL "<"
SIZE 6 BY 1.14.

DEFINE VARIABLE EDITOR-1 AS CHARACTER
VIEW-AS EDITOR SCROLLBAR-VERTICAL
SIZE 143 BY 11.91 NO-UNDO.

DEFINE IMAGE IMAGE-1
FILENAME "images\s2_banr":U
SIZE 148 BY .95.

DEFINE VARIABLE Selectfld AS CHARACTER
VIEW-AS SELECTION-LIST SINGLE SORT SCROLLBAR-VERTICAL
SIZE 38 BY 9 NO-UNDO.

DEFINE VARIABLE Selectfld2 AS CHARACTER
VIEW-AS SELECTION-LIST SINGLE SCROLLBAR-VERTICAL
SIZE 38 BY 9 NO-UNDO.

DEFINE VARIABLE Selecttable AS CHARACTER
VIEW-AS SELECTION-LIST SINGLE SCROLLBAR-VERTICAL
SIZE 38 BY 9 NO-UNDO.


/* ************************ Frame Definitions *********************** */

DEFINE FRAME fMain
Selecttable AT ROW 2.67 COL 3 NO-LABEL
Selectfld AT ROW 2.67 COL 44 NO-LABEL
Selectfld2 AT ROW 2.67 COL 92 NO-LABEL
btnopenqry AT ROW 2.91 COL 132
Btnadd AT ROW 4.57 COL 84
Btnremove AT ROW 6.24 COL 84
EDITOR-1 AT ROW 11.95 COL 3 NO-LABEL
Btnfirst AT ROW 24.57 COL 44
btnnext AT ROW 24.57 COL 60
btnprev AT ROW 24.57 COL 76
btnlast AT ROW 24.57 COL 92
IMAGE-1 AT ROW 1.24 COL 2
WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1
SIZE 149.8 BY 25.


/* *********************** Procedure Settings ************************ */

&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
Type: SmartWindow
Allow: Basic,Browse,DB-Fields,Query,Smart,Window
Container Links:
*/
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS

/* ************************* Create Window ************************** */

&ANALYZE-SUSPEND _CREATE-WINDOW
IF SESSION
biggrin.gif
ISPLAY-TYPE = "GUI":U THEN
CREATE WINDOW wWin ASSIGN
HIDDEN = YES
TITLE = "Dynamic Buffer"
HEIGHT = 25
WIDTH = 150
MAX-HEIGHT = 28.81
MAX-WIDTH = 150
VIRTUAL-HEIGHT = 28.81
VIRTUAL-WIDTH = 150
RESIZE = no
SCROLL-BARS = no
STATUS-AREA = no
BGCOLOR = ?
FGCOLOR = ?
THREE-D = yes
MESSAGE-AREA = no
SENSITIVE = yes.
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
/* END WINDOW DEFINITION */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB wWin
/* ************************* Included-Libraries *********************** */

{src/adm2/containr.i}

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


/* *********** Runtime Attributes and AppBuilder Settings *********** */

&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR WINDOW wWin
VISIBLE,,RUN-PERSISTENT */
/* SETTINGS FOR FRAME fMain
*/
ASSIGN
Selectfld:AUTO-RESIZE IN FRAME fMain = TRUE.

ASSIGN
Selectfld2:AUTO-RESIZE IN FRAME fMain = TRUE.

IF SESSION
biggrin.gif
ISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wWin)
THEN wWin:HIDDEN = yes.

/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME



/* ************************ Control Triggers ************************ */

&Scoped-define SELF-NAME wWin
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wWin wWin
ON END-ERROR OF wWin /* Dynamic Buffer */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
/* This case occurs when the user presses the "Esc" key.
In a persistently run window, just ignore this. If we did not, the
application would exit. */
IF THIS-PROCEDURE:pERSISTENT THEN RETURN NO-APPLY.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wWin wWin
ON WINDOW-CLOSE OF wWin /* Dynamic Buffer */
DO:
/* This ADM code must be left here in order for the SmartWindow
and its descendents to terminate properly on exit. */
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME Btnadd
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btnadd wWin
ON CHOOSE OF Btnadd IN FRAME fMain /* > */
DO:
run additem.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME Btnfirst
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btnfirst wWin
ON CHOOSE OF Btnfirst IN FRAME fMain /* First */
DO:

IF VALID-HANDLE(qh) THEN DO:
qh:get-first.

RUN displayflds.

END. /*if valid-handle*/

END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME btnlast
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnlast wWin
ON CHOOSE OF btnlast IN FRAME fMain /* Last */
DO:
IF VALID-HANDLE(qh) THEN DO:

qh:GET-LAST.

RUN displayflds.

END. /*valid-handle*/

END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME btnnext
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnnext wWin
ON CHOOSE OF btnnext IN FRAME fMain /* Next */
DO:
IF VALID-HANDLE(qh) THEN DO:
qh:get-NEXT.
IF (qh:Query-off-end) THEN DO:
MESSAGE "This is the last record." VIEW-AS ALERT-BOX INFO BUTTONS OK.
RETURN.
END. /*if qry off end*/
RUN displayflds.
END. /*valid-handle*/
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME btnopenqry
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnopenqry wWin
ON CHOOSE OF btnopenqry IN FRAME fMain /* Open Query */
DO:
IF VALID-HANDLE(qh) THEN DELETE WIDGET qh.
EDITOR-1:SCREEN-VALUE = "".
CREATE BUFFER bh FOR TABLE selecttable:SCREEN-VALUE.
CREATE query qh.
qh:SET-BUFFERS(bh).
qh:query-prepare("FOR EACH " + selecttable:SCREEN-VALUE + " NO-LOCK ").
qh:query-open.
qh:get-first.

RUN displayflds.


END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME btnprev
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnprev wWin
ON CHOOSE OF btnprev IN FRAME fMain /* Prev */
DO:
IF VALID-HANDLE(qh)THEN DO:

qh:GET-PREV.
IF (qh:Query-off-end) THEN DO:

MESSAGE "This is the first record." VIEW-AS ALERT-BOX INFO BUTTONS OK.
RETURN.

END. /*if qry off end*/

RUN displayflds.

END. /*valid-handle*/
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME Btnremove
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btnremove wWin
ON CHOOSE OF Btnremove IN FRAME fMain /* < */
DO:
run removeitem.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME Selectfld
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Selectfld wWin
ON MOUSE-SELECT-DBLCLICK OF Selectfld IN FRAME fMain
DO:
run additem.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME Selectfld2
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Selectfld2 wWin
ON MOUSE-SELECT-DBLCLICK OF Selectfld2 IN FRAME fMain
DO:
run removeitem.
END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME Selecttable
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Selecttable wWin
ON VALUE-CHANGED OF Selecttable IN FRAME fMain
DO:
DEF VAR ok AS LOGICAL NO-UNDO.
ASSIGN
selectfld:LIST-ITEMS = ""
selectfld2:LIST-ITEMS = "".

FIND FIRST _file WHERE _file-name = selecttable:SCREEN-VALUE NO-LOCK NO-ERROR.

IF AVAIL _file THEN DO:

FOR EACH _field OF _file NO-LOCK BY _field-name:

ok = selectfld:ADD-LAST(_field-name).

END. /*for each _field*/

END. /*if avail _file*/
IF VALID-HANDLE(qh) THEN
DELETE WIDGET qh.
CLEAR FRAME dspframe ALL NO-PAUSE.

END.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&UNDEFINE SELF-NAME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK wWin


/* *************************** Main Block *************************** */

/* Include custom Main Block code for SmartWindows. */
{src/adm2/windowmn.i}

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


/* ********************** Internal Procedures *********************** */

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE additem wWin
PROCEDURE additem :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DEF VAR OK AS LOGICAL NO-UNDO.

DO WITH FRAME fmain:

IF selectfld:SCREEN-VALUE <> "" AND selectfld:SCREEN-VALUE <> ? THEN DO:
ok = selectfld2:ADD-LAST(selectfld:SCREEN-VALUE).
ok = selectfld
biggrin.gif
ELETE(selectfld:SCREEN-VALUE).
END. /*selectfld:screen-value <> ""*/

END. /*do with frame fmain*/

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects wWin _ADM-CREATE-OBJECTS
PROCEDURE adm-create-objects :
/*------------------------------------------------------------------------------
Purpose: Create handles for all SmartObjects used in this procedure.
After SmartObjects are initialized, then SmartLinks are added.
Parameters: <none>
------------------------------------------------------------------------------*/

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI wWin _DEFAULT-DISABLE
PROCEDURE disable_UI :
/*------------------------------------------------------------------------------
Purpose: DISABLE the User Interface
Parameters: <none>
Notes: Here we clean-up the user-interface by deleting
dynamic widgets we have created and/or hide
frames. This procedure is usually called when
we are ready to "clean-up" after running.
------------------------------------------------------------------------------*/
/* Delete the WINDOW we created */
IF SESSION
biggrin.gif
ISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wWin)
THEN DELETE WIDGET wWin.
IF THIS-PROCEDURE:pERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE displayflds wWin
PROCEDURE displayflds :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DEF VAR ok AS LOGICAL NO-UNDO.


EDITOR-1:SCREEN-VALUE IN FRAME {&FRAME-NAME} = "".

dsploop: REPEAT x = 1 to NUM-ENTRIES(selectfld2:LIST-ITEMS IN FRAME Fmain):

FIND FIRST _field WHERE _field-name = ENTRY(x,selectfld2:LIST-ITEMS IN FRAME fmain)
NO-LOCK NO-ERROR.
fh = bh:BUFFER-FIELD(ENTRY(x,selectfld2:LIST-ITEMS IN FRAME fmain)).

IF _data-type = "CHAR" THEN DO:
ok = EDITOR-1:INSERT-STRING(_label + ": " + SUBSTRING(fh:BUFFER-VALUE,1, 140) + CHR(10)).
END. /*data_type = date*/

ELSE DO:
ok = EDITOR-1:INSERT-STRING(_label + ": " + STRING(fh:BUFFER-VALUE) + CHR(10)) .
END. /*else do*/

END. /*dsploop*/



END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI wWin _DEFAULT-ENABLE
PROCEDURE enable_UI :
/*------------------------------------------------------------------------------
Purpose: ENABLE the User Interface
Parameters: <none>
Notes: Here we display/view/enable the widgets in the
user-interface. In addition, OPEN all queries
associated with each FRAME and BROWSE.
These statements here are based on the "Other
Settings" section of the widget Property Sheets.
------------------------------------------------------------------------------*/
DISPLAY Selecttable Selectfld Selectfld2 EDITOR-1
WITH FRAME fMain IN WINDOW wWin.
ENABLE Selecttable Selectfld Selectfld2 btnopenqry Btnadd Btnremove EDITOR-1
Btnfirst btnnext btnprev btnlast IMAGE-1
WITH FRAME fMain IN WINDOW wWin.
{&OPEN-BROWSERS-IN-QUERY-fMain}
VIEW wWin.
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE exitObject wWin
PROCEDURE exitObject :
/*------------------------------------------------------------------------------
Purpose: Window-specific override of this procedure which destroys
its contents and itself.
Notes:
------------------------------------------------------------------------------*/

APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN.

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE initializeObject wWin
PROCEDURE initializeObject :
/*------------------------------------------------------------------------------
Purpose: Super Override
Parameters:
Notes:
------------------------------------------------------------------------------*/
DEF VAR ok AS LOGICAL NO-UNDO.
DEF VAR lfirstone AS LOGICAL NO-UNDO.
DEF VAR lfilename AS CHAR NO-UNDO.

lfirstone = TRUE.
DO WITH FRAME fmain:

FOR EACH _file NO-LOCK BY _file-name:

ok = selecttable:ADD-LAST(_file-name).

IF lfirstone THEN DO:

FOR EACH _field OF _file NO-LOCK BY _field-name:

ok = selectfld:ADD-LAST(_field-name).

END. /*for each _field*/
lfilename = _file._file-name.
lfirstone = FALSE.

END. /*lfirstone*/


END. /*for each _file*/
selecttable = lfilename.


END. /*do with frame */

RUN SUPER.

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE removeitem wWin
PROCEDURE removeitem :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DEF VAR OK AS LOGICAL NO-UNDO.

DO WITH FRAME fmain:

IF selectfld2:SCREEN-VALUE <> "" AND selectfld2:SCREEN-VALUE <> ? THEN DO:

ok = selectfld:ADD-LAST(selectfld2:SCREEN-VALUE).
ok = selectfld2
biggrin.gif
ELETE(selectfld2:SCREEN-VALUE).

END. /*selectfld2:screen-value <> ""*/

END. /*do with frame fmain*/

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

[/code]

[This message has been edited by progresstalk (edited 14 January 2000).]
 
Top