Display all buffer-fields and -values

dunno

New Member
Hey guys,

is there a function / procedure in ABL like var_dump in PHP to display easy all buffer-fields and -values.

Example:
Code:
DEFINE VARIABLE vWHTable AS WIDGET-HANDLE      NO-UNDO.

CREATE BUFFER vWHTable FOR TABLE "customer".
vWHTable:FIND-FIRST().

DISPLAY vWHTable
DELETE WIDGET vWHTable.

I try to display all fields (custnum, country, name, address... ) with it's values.
And "DISPLAY handle" requires the INTEGER function to display "DISPLAY INTEGER(handle)" but shows only the Handle-ID (or whatever this is).


Hope you can understand my english.
 

TomBascom

Curmudgeon
Why wouldn't you do it like this?

Code:
find first customer no-lock.
display customer.

If you really want to do it completely dynamically you're going to have to do a lot more work.
 

RealHeavyDude

Well-Known Member
The "vWHTable" is a variable of type handle - it will always contain the pointer to the dynamic buffer object. Therefore, if you want to display the values of all fields you must loop through the buffer field objects of the dynamic buffer. Something like the following code should do ( please don't copy/paste the code as I didn't test it thouroughly ... ):

DEFINE hField AS HANDLE NO-UNDO.
DEFINE iFieldLoop AS INTEGER NO-UNDO.

DO iFieldLoop = 1 TO vWHTable:NUM-FIELDS:

ASSIGN hField = vWHTable:BUFFER-FIELD ( iLoop ).

MESSAGE hField:NAME /* Name of the database field */ SKIP
hField:BUFFER-VALUE
VIEW-AS ALERT-BOX INFO.


END.
 

dunno

New Member
Well, I have to do it dynamically. I'm deleting dynamically unused records and log all values to restore it probably later.

I found a solution.
Code:
DEFINE VARIABLE i AS INTEGER     NO-UNDO.
DO i = 1 TO vwhtable:NUM-FIELDS:
  DISPLAY vwhtable:BUFFER-FIELD(i):NAME vwhtable:BUFFER-FIELD(i):BUFFER-VALUE.
END.
But would be interesting, if there's already a function...

Edit: thx RealHeavyDude :)
 

TomBascom

Curmudgeon
Not exactly. But you might find the WRITE-XML() method to be a suitable substitute for your purpose.

If you're going to stick with the approach above you should check the buffer-field's extent attribute to make sure you don't have an array field. And you might want to check to see if you have any LOBs as well.
 
Top