Can Xbrowse show ALL used Mem variables ?

Post Reply
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Can Xbrowse show ALL used Mem variables ?

Post by Marc Venken »

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 20.08 with Harbour
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Can Xbrowse show ALL used Mem variables ?

Post by nageswaragunupudi »

Please try this program

Code: Select all

#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
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Re: Can Xbrowse show ALL used Mem variables ?

Post by Marc Venken »

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 20.08 with Harbour
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Can Xbrowse show ALL used Mem variables ?

Post by Antonio Linares »

Marc,

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

Code: Select all

#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
Post Reply