Save memory vars to text file

Save memory vars to text file

Postby Jeff Barnes » Sun Jan 28, 2007 1:56 am

Hi All,


Is there a way to store ALL memory var's to a text file?

I've tried SAVE TO but it does not give me ALL var's.


Thanks,

Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Frank Demont » Sun Jan 28, 2007 10:49 am

Jeff

From ng :

SAVE copies public and private memory variables visible within the
current procedure or user-defined function to a memory (.mem) file.
Arrays and local and static variables, however, cannot be SAVEd. When
variables are SAVEd, they are copied without any reference to scope.
Variables hidden by PRIVATE or LOCAL declarations are not SAVEd.


However , in errorsysw.prg you have an example from how local variables from a procedure are retrieved

Frank
Frank Demont
 
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Postby Jeff Barnes » Sun Jan 28, 2007 5:42 pm

Actually, what I am looking for is something that will store the memoy in a format similar to:

cTextValue = "This is the text value"
nNumberValue = 123456

etc...

I am looking to add some troubleshooting / revocery options to one of my apps but I need to know what is stored in memory.


Thanks,
Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Jeff Barnes » Sun Jan 28, 2007 7:29 pm

I found functions in the manual called:

LogStatics() and Scan()

It looks like these might help me do what I want but I can not get either of them to work.


Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Rochinha » Sun Jan 28, 2007 7:33 pm

Friend

You can use .INI files to store variables names end data.

MyINI.INI
Code: Select all  Expand view  RUN
[VARIABLES]
cTextValue="This is the text value"
nNumberValue=123456


Use this example:
Code: Select all  Expand view  RUN
// Sample showing how to use INI files with FiveWin

#include "FiveWin.ch"

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

function Main()

   local oWnd, oIni, oBar
   local cTitle, cMsg, cLogo
   local nRow  := 3, nCol := 5, nWidth := 50, nHeight := 50
   local cBtn1 := "", cBtn2 := ""

   INI oIni FILE ".\MyApp.ini"
      GET cTitle  SECTION "main" ENTRY "Title"   OF oIni DEFAULT "FiveWin App"
      GET cMsg    SECTION "main" ENTRY "Message" OF oIni DEFAULT "Main message"

      GET cLogo   SECTION "Logo" ENTRY "File"    OF oIni
      GET nRow    SECTION "Logo" ENTRY "Row"     OF oIni
      GET nCol    SECTION "Logo" ENTRY "Col"     OF oIni
      GET nWidth  SECTION "Logo" ENTRY "Width"   OF oIni
      GET nHeight SECTION "Logo" ENTRY "Height"  OF oIni

      GET cBtn1   SECTION "ButtonBar" ENTRY "Button1" OF oIni
      GET cBtn2   SECTION "ButtonBar" ENTRY "Button2" OF oIni
   ENDINI

   DEFINE WINDOW oWnd FROM 1, 5 TO 20, 60 ;
      TITLE cTitle

   DEFINE BUTTONBAR oBar OF oWnd

   if ! Empty( cBtn1 )
      DEFINE BUTTON OF oBar FILE cBtn1
   endif
   if ! Empty( cBtn2 )
      DEFINE BUTTON OF oBar FILE cBtn2
   endif

   SET MESSAGE OF oWnd TO cMsg

   @ nRow, nCol BITMAP FILE cLogo SIZE nWidth, nHeight OF oWnd

   ACTIVATE WINDOW oWnd

return nil

//----------------------------------------------------------------------------//
Rochinha
 
Posts: 310
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo

Postby Jeff Barnes » Sun Jan 28, 2007 8:19 pm

I am looking for a function that will give me ALL my mem vars ... depending where my user is in the prtogram the vars will have different names so the .ini solution will not work for me.


Thanks anyway.

Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Enrico Maria Giordano » Sun Jan 28, 2007 8:33 pm

Jeff Barnes wrote:I found functions in the manual called:

LogStatics() and Scan()

It looks like these might help me do what I want but I can not get either of them to work.


Jeff


They are for STATIC variables only.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Jeff Barnes » Sun Jan 28, 2007 8:56 pm

Hi Enrico,

I realize that they are for Static vars only but I still can not get them to work.

When I compile I get:

Error: Unresolved external '_HB_FUN_LOGSTATIC'

If I try to compile the \FWH\Source\Functions\Static.prg I get:

Error: Unresolved external '_HB_FUN_STATIC'

I can't seem to win on this one.

Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Enrico Maria Giordano » Sun Jan 28, 2007 9:36 pm

This is a working sample:

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


STATIC TEST1 := "This is a test 1"
STATIC TEST2 := "This is a test 2"
STATIC TEST3 := "This is a test 3"


FUNCTION MAIN()

    LOCAL i

    ? NSTATICS(), HB_DBG_VMVARSLEN()

    FOR  i = 1 TO 3
        ? HB_DBG_VMVARSGET( i )
    NEXT

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Jeff Barnes » Sun Jan 28, 2007 11:41 pm

Enrico,

This gets me a bit closer but how do you get the var's name?

Thanks again,

Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Enrico Maria Giordano » Mon Jan 29, 2007 8:11 am

I'm not sure you can get the name of a STATIC var. You better ask to xHarbour newsgroup. Meanwhile, this is a better sample:

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


STATIC TEST1 := "This is a test 1"
STATIC TEST2 := "This is a test 2"
STATIC TEST3 := "This is a test 3"


FUNCTION MAIN()

    LOCAL aStatics := __VMVARSLIST()

    LOCAL i

    ? NSTATICS(), __VMVARSLEN(), LEN( aStatics )

    FOR  i = 1 TO 3
        ? __VMVARSGET( i ), aStatics[ i ]
    NEXT

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Mon Jan 29, 2007 10:31 am

Jeff,

You can only get the static variables names (same for locals) if the PRG has been compiled using /b (debug info). Without /b the names are lost (not used at all)
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 44 guests