project QadFinancials > class TDebug > method ExportObjectHTML


Parameters


ihObjectHandleinputhandleSpecify the handle to the temp-table; syntax: temp-table a:handle
icOutputFileNameinputcharacterSpecify the output file; Example: "c:\temp\temp.htm"
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/tdebug.p)

define variable vhBuf as handle     no-undo.
define variable vhFld as handle     no-undo.
define variable viIdx as integer    no-undo.
define variable vh_query_show as handle no-undo.
define variable vc_query as character no-undo.

/* ========================================================================
   This procedure exports content of object to HTML file
   Usage: 
   run program/TDebug.p (input temp-table a:handle,
                         input "c:\temp\temp.htm",
                         output viFcReturnSuper).
   ======================================================================== */

if ihObjectHandle = ? or
   not valid-handle(ihObjectHandle)
then return.

if not icOutputFileName = ? 
then do while true on error undo, retry:
    if retry 
    then do:
        assign icOutputFileName = '':U.
        leave.
    end.    
    
    output to value(icOutputFileName) append.
    
    leave.
end.    

case ihObjectHandle:type:
    when "temp-table":U
    then do:
        create query vh_query_show in widget-pool "non-persistent".
        vhBuf = ihObjectHandle:default-buffer-handle.
        vh_query_show:add-buffer( vhBuf ).
        vh_query_show:query-prepare( "for each ":U + vhBuf:table ).
        
        put unformatted vc_query skip.
        
        vh_query_show:query-open().
        vh_query_show:get-first().
        
        put unformatted "<table border=2 style='border-collapse: collapse; font-family:Arial; font-size:10pt' bordercolor=#111111 cellpadding=0 cellspacing=0>":U skip.
        /* name of temp table */
        put unformatted "<tr>":U skip.
        put unformatted "<td>":U string(now) "</td>":U.
        put unformatted "<td span=99>":U "TEMP-TABLE:":U ihObjectHandle:name "</td>":U.
        put unformatted "</tr>":U skip.

        /* name of columns */
        put unformatted "<tr>":U skip.
        do viIdx = 1 to vhBuf:num-fields:
            vhFld = vhBuf:buffer-field(viIdx).
            put unformatted "<td>":U vhFld:name "</td>":U.
        end.
        put unformatted "</tr>":U skip.
        
        /* values of row */
        do while not vh_query_show:query-off-end:
            put unformatted "<tr>":U skip.
            
            do viIdx = 1 to vhBuf:num-fields:
                vhFld = vhBuf:buffer-field(viIdx).
                put unformatted "<td>":U vhFld:buffer-value "</td>":U.
            end.
            
            put unformatted "</tr>":U skip.
            
            vh_query_show:get-next().
        end.
        
        put unformatted "</table>":U skip.
        
        vh_query_show:query-close().
        
        delete object vh_query_show.
        assign vh_query_show = ?.
    end.
end case.

if icOutputFileName <> '':U
then output close.