How to Process Xbrowse Command data

How to Process Xbrowse Command data

Postby Marc Venken » Wed Jul 10, 2024 8:11 am

Xbrowse can handle many data and in my case, I use Xbrowse command to show Json data.

hb_JsonDecode( hJson, @hDatos ) // -> Hash
xbrowser(hDatos) Title "hDatos"

This will give me a xbrowse with title and data...

option 1 :
Trying to export to dbf is failing in my code. (And can cause issues with fieldnames that are only 10 char long in dbf)

xbrowser hDatos setup ( obrw:autofit(), oBrw:bRClicked := { |r,c,f,o| o:ToDbf( "download.dbf", nil, nil, .t. ) } )

Option 2 :

How can I process this Xbrowse in a Do/While loop ? Wich setup is needed to call my function for this do while ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to Process Xbrowse Command data

Postby Marc Venken » Fri Jul 12, 2024 1:34 pm

I found a earlier post of Mr. Rao that will do the job. preseded the oDbf:toArray()

I can adapt this function to fill a dbf.

Code: Select all  Expand view


  hb_JsonDecode( uResponse, @hDatos )     // -> Hash
  xbrowser ( hDatos )TITLE "R Click" setup ( oBrw:bRClicked := { |r,c,f,oBrw| aResult := XbrToArray( oBrw ) } )


function XbrToArray( Self, aCols )

   local aData    := {}
   local nRows    := ::nLen
   local nRow, bm

   if nRows > 0
      if aCols == nil
         aCols    := ::GetVisibleCols()
      else
         aCols    := { |o,i| aCols[ i ] := ::oCol( i ) }
      endif

      aData       := Array( nRows, Len( aCols ) )

      //  Zet de headers mee in de array op lijn 1
      for i = 1 to len(aCols)
        aData[1][I] = ::cHeaders[I]
      next

      xbrowser(aData) title "Adata Test"

      bm          := ::BookMark

      Eval( ::bGoTop, Self )

      for nRow := 2 to nRows
         AEval( aCols, { |o,i| aData[ nRow, i ] := o:Value } )
         Eval( ::bSkip, 1 )
      next

      ::BookMark  := bm

   endif
   xbrowser(aData) COLUMNS 1,3 SETUP ( oBrw:cHeaders := {"ID","Naam"}) Title "aData extracted"

return aData


 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 55 guests