Results 1 to 3 of 3

Thread: Struct Viewer debugging tool (19.0+ only)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Location
    Fresno, CA
    Posts
    1,072

    Default Struct Viewer debugging tool (19.0+ only)

    The Struct Viewer is a debugging tool that can be used when working with struct arrays and nested structs. It provides a different view of struct array data from the Watches window; instead of a treeview structure, struct arrays are presented in a grid with each row corresponding to an element in the array and each column a member of the struct. This makes it easy for instance to easily see the values of a particular member in a struct array for different elements. A struct is displayed in a two column grid with the member names listed in the first column and the values in the second column (much like the Watches window).

    For nested structs/struct arrays, the grid cell will contain the JSON data. Double click on the cell to drill down and view the struct/struct array in a new Struct Viewer window.

    The Struct Viewer code is in a library. The attached file is meant to be unzipped in your DataFlex 19.0 Examples folder. It includes a sample program for the Order Entry workspace that demonstrates usage. Overwrite the Order Entry SWS file when unzipping as this SWS includes the demo project (StructViewerTest.src) and adds the library to the Order Entry workspace.

    Since the Struct Viewer uses the JSON class that is new to 19.0, it cannot be used with previous versions of the Studio.

    In your code, you can invoke the struct viewer with a single line:

    Code:
    Get New (RefClass(cStructViewer)) 0 Vendors "Vendors" to hoView
    This will create a new struct viewer modal panel, load the data in the Vendors struct, activate the modal panel ("Vendors" will be the modal panel's caption), and destroy the panel and grid objects when you close the panel. (It is not necessary to send destroy to hoView.) (The second parameter, 0, is a dummy parameter that seems to be required in this case due to some low-level runtime stuff that goes on with the creation of the ModalPanel object.)

    If program execution is paused, it is also possible to invoke a struct viewer by entering the following into the Watches window:

    Code:
    (New(Self,U_cStructViewer,0,Vendors,"Vendors"))
    Note: RefClass is a compiler thing so you have to use the decorated class name in Watches. I'm also not sure about any side effects from activating a modal panel during a debugging session, but it seems to work ok.

    (New is a function defined in cObject_new.pkg and is similar to the standard Create function, except it passes any additional parameters after the class ID on to the object constructor.)

    The sample program provided for the Order Entry workspace displays two struct arrays. The first one is a simple example that contains all of the data from the Vendors table. The second one is more complicated and contains all of the order entry data with nested structs/struct arrays. The Order Entry struct contains structs with the customer, sales person, and line item data. The line item data is a struct array that contains a struct for each line item data and inventory item data for that line.

    Also, Ctrl+C can be used on the struct viewer to copy all of the data to the clipboard in tab delimited format.


    Click image for larger version. 

Name:	Struct Viewer Screenshot.png 
Views:	138 
Size:	52.5 KB 
ID:	11019
    Attached Files Attached Files
    Best regards,

    Matt Davidian
    Datatech
    Fresno, CA
    www.datatechag.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •