Can Xbrowse show ALL used Mem variables ?

Can Xbrowse show ALL used Mem variables ?

Postby Marc Venken » Thu Apr 02, 2020 1:35 pm

As a inspector, we can use : xbrowser(oWnd)

Can we also use it to show all memory variables that are in use ?

Now I put a msginfo(cData) to see what is de value if i'm not sure..

Maybe it can be done with the power of Xbrowse(r)
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Can Xbrowse show ALL used Mem variables ?

Postby nageswaragunupudi » Fri Apr 03, 2020 2:46 am

Please try this program
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function main( cParam )

   local nn := "kk"

   func2( 2, 3, 4 )

return nil

function func2( a, b, c )

   local x := 20, y := 30

   func3( a+b, b+c, nil )

return nil

function func3( x, y, z )

   local p := 100, q, r := date()

   StackVars( .t. )

return nil

//----------------------------------------------------------------------------//

function StackVars( lBrw )

   local n := 1, aInfo := {}, nParam, nLocal

   while ! Empty( ProcName( n ) )

#ifdef __XHARBOUR__

      AAdd( aInfo, { ProcName( n ), cFileNoPath( ProcFile( n ) ), ProcLine( n ),  {}, {} } )

#endif

      if !Empty( aInfo )

         for nParam = 1 to ParamCount( n )
            AAdd( ATail( aInfo )[ 4 ], GetParam( n, nParam ) )
         next

         for nLocal = 1 to LocalCount( n )
            AAdd( ATail( aInfo )[ 5 ], GetLocal( n, nLocal ) )
         next

      endif

#ifndef __XHARBOUR__

      AAdd( aInfo, { ProcName( n ), cFileNoPath( ProcFile( n ) ), ProcLine( n ), {}, {} } )

#endif

      n++
   end

#ifndef __XHARBOUR__

      if !Empty( aInfo )

         for nParam = 1 to ParamCount( n )
            AAdd( ATail( aInfo )[ 4 ], GetParam( n, nParam ) )
         next

         for nLocal = 1 to LocalCount( n )
            AAdd( ATail( aInfo )[ 5 ], GetLocal( n, nLocal ) )
         next

      endif

#endif

   if lBrw == .t.
      BrowseStack( aInfo )
   endif

return aInfo

function BrowseStack( aStack )

   local oDlg, oFont, oBrw1, oBrw2, oBrw3, nCol

   DEFINE FONT oFont NAME "ARIAL" SIZE 0,-12
   DEFINE DIALOG oDlg SIZE 710,300 PIXEL TRUEPIXEL FONT oFont ;
      TITLE cFileNoPath( ExeName() ) + " : STACK" RESIZABLE

   nCol  := 10

   @ 10, nCol XBROWSE oBrw1 SIZE 300,-10 PIXEL OF oDlg ;
      DATASOURCE aStack COLUMNS 1, 2, 3 ;
      HEADERS "PROCEDURE", "MODULE", "LINE" ;
      COLSIZES nil, -12, "999999" ;
      CELL LINES NOBORDER FOOTERS

   WITH OBJECT oBrw1
      :nStretchCol   := 1
      :lHScroll      := .f.
      :lVScroll      := .f.
      :bRecSelData   := { |o| o:BookMark }
      :bRecSelFooter := { |o| o:nLen }
      :nRecSelWidth  := "99"

      :bChange       := < ||
         oBrw2:aArrayData  := oBrw1:aRow[ 4 ]
         oBrw2:GoTop()
         oBrw2:Refresh()
         oBrw3:aArrayData  := oBrw1:aRow[ 5 ]
         oBrw3:GoTop()
         oBrw3:Refresh()

         return nil
         >

      :CreateFromCode()
   END

   nCol  += oBrw1:nWidth

   @ 10, nCol XBROWSE oBrw2 SIZE 180,-10 PIXEL OF oDlg ;
      DATASOURCE aStack[1][4] ;
      COLUMNS { || ValType( oBrw2:aRow ) }, 1 ;
      HEADERS "TYP", "PARAM" ;
      CELL LINES NOBORDER FOOTERS

   WITH OBJECT oBrw2
      :nStretchCol   := 2
      :lHScroll      := .f.
      :lVScroll      := .f.
      :bRecSelData   := { |o| o:BookMark }
      :bRecSelFooter := { |o| o:nLen }
      :nRecSelWidth  := "99"

      :CreateFromCode()
   END

   nCol  += oBrw2:nWidth

   @ 10, nCol XBROWSE oBrw3 SIZE 180,-10 PIXEL OF oDlg ;
      DATASOURCE aStack[1][5] ;
      COLUMNS { || ValType( oBrw3:aRow ) }, 1 ;
      HEADERS "TYP", "LOCAL" ;
      CELL LINES NOBORDER FOOTERS

   WITH OBJECT oBrw3
      :nStretchCol   := 2
      :lHScroll      := .f.
      :lVScroll      := .f.
      :bRecSelData   := { |o| o:BookMark }
      :bRecSelFooter := { |o| o:nLen }
      :nRecSelWidth  := "99"

      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Can Xbrowse show ALL used Mem variables ?

Postby Marc Venken » Fri Apr 03, 2020 8:32 am

Is it possible to show the var names also ?

cData:= "Test"

Test is in the browse

Can the varname cData also be there ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Can Xbrowse show ALL used Mem variables ?

Postby Antonio Linares » Fri Apr 03, 2020 8:17 pm

Marc,

https://harbour.github.io/doc/harbour.html#__mvdbginfo

Code: Select all  Expand view  RUN
#include "hbmemvar.ch"

MEMVAR cPublic
MEMVAR cPrivate
MEMVAR ccPublic
MEMVAR ccPrivate

PROCEDURE Main()

   LOCAL nCount, tmp, xValue, cName

   nCount := __mvDbgInfo( HB_MV_PUBLIC )
   FOR tmp := 1 TO nCount
      xValue := __mvDbgInfo( HB_MV_PUBLIC, tmp, @cName )
      ? tmp, cName, xValue
   NEXT

   ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
   ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

   PUBLIC cPublic := "cPublic in MAIN"

   ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
   ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

   PRIVATE cPrivate := "cPrivate in MAIN"

   ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
   ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

   CountMemvars()

   ? "Back in Main"
   ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
   ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

   RETURN

STATIC PROCEDURE CountMemvars()

   LOCAL nCount, tmp, xValue, cName

   PUBLIC ccPublic := "ccPublic"
   PRIVATE ccPrivate := "ccPrivate"

   ? "In CountMemvars"
   ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
   ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

   PRIVATE cPublic := "cPublic"

   ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
   ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

   nCount := __mvDbgInfo( HB_MV_PRIVATE ) + 1
   FOR tmp := 1 TO nCount
      xValue := __mvDbgInfo( HB_MV_PRIVATE, tmp, @cName )
      ? tmp, "=", cName, xValue
   NEXT

   nCount := __mvDbgInfo( HB_MV_PUBLIC ) + 1
   FOR tmp := 1 TO nCount
      xValue := __mvDbgInfo( HB_MV_PUBLIC, tmp, @cName )
      ? tmp, "=", cName, xValue
   NEXT

   RETURN
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 76 guests