FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour asave/aread
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
asave/aread
Posted: Tue Oct 11, 2011 08:14 AM

These functions are not saving and reading a array on the right way. It seems, the aread is ok but asave not saving normal. An older app reads a array saved with a old version from FWH normal. But if i write back with asave, the array ist destructed!

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: asave/aread
Posted: Tue Oct 11, 2011 09:51 AM

You are right. We have been experiencing the problem with "some recent" versions of xHarbour. This had also effected XBrowse's SaveState() method.

I suggest three alternatives:

1. Copy the ASave function from windows.prg into your module that is using ASave as a static function.

2. Create a new public function MyASave with the same code as ASave in windows.prg and use MyASave instead of ASave.

3. Much better and I recommend this: If you are using one of the latest versions of FWH, use FW_ValToExp( aArray ) function.

Usage:
cArray := FW_ValToExp( aArray )

Save cArray anywhere. cArray is pure asci text unlike ASave which gives a binary string. This can be saved in ini files also.

For restoring, read cArray from the saved file and

aArray := &( cArray )
Simple macro is enough. No need to use any function.

Note: FW ASave function can even save objects. FW_ValToExp() can not.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: asave/aread
Posted: Tue Oct 11, 2011 09:20 PM

FW_ValToExp( aArray ) should be visible in FIVEWIN DOKU!

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: asave/aread
Posted: Wed Oct 12, 2011 05:03 AM
Added to FiveWin Wiki with a usage example :-)

Regards
Anser
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: asave/aread
Posted: Wed Oct 12, 2011 07:03 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: asave/aread
Posted: Wed Oct 12, 2011 09:27 AM
here is another way to save / load 2-dimensional arrays in / from a memofield

Code (fw): Select all Collapse
METHOD LoadShares ()

  LOCAL cAll := (::cAlias)->Shares                     // load string from memo
  LOCAL cShare := "", aShare := {}, aSh := {}
  LOCAL nCount := 0 //NumAt (";", cAllIP), i

  DO WHILE .T.
    cShare := Token( cAll, "|", ++nCount )

     IF Empty( cShare )
       // AAdd (aShare, {"","Keine Eintrõge"} )
        EXIT
     ENDIF
     aSh := {Token (cShare,";",1),Token (cShare,";",2)}
     AAdd (aShare, aSh )
     //? aShare[1,1], aShare[1,2]
  ENDDO
  IF Len (aShare) = 0; AAdd (aShare, {"","Keine Einträge"} );ENDIF

RETURN (aShare)


METHOD SaveShares (aSh)

  LOCAL i
  LOCAL cSh := ""

  FOR i := 1 TO Len (aSh)
     cSh += aSh[i,1]+";"+aSh[i,2]+"|"
  NEXT
  cSh := Left (cSh, Len(cSh)-1)
   (::cAlias)->Shares := cSh

RETURN (cSh)
kind regards

Stefan

Continue the discussion