asave/aread

asave/aread

Postby byte-one » Tue Oct 11, 2011 8: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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: asave/aread

Postby nageswaragunupudi » Tue Oct 11, 2011 9: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
User avatar
nageswaragunupudi
 
Posts: 10245
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: asave/aread

Postby byte-one » Tue Oct 11, 2011 9:20 pm

FW_ValToExp( aArray ) should be visible in FIVEWIN DOKU!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: asave/aread

Postby anserkk » Wed Oct 12, 2011 5:03 am

Added to FiveWin Wiki with a usage example :)

Regards
Anser
User avatar
anserkk
 
Posts: 1329
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: asave/aread

Postby Antonio Linares » Wed Oct 12, 2011 7:03 am

regards, saludos

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

Re: asave/aread

Postby StefanHaupt » Wed Oct 12, 2011 9:27 am

here is another way to save / load 2-dimensional arrays in / from a memofield

Code: Select all  Expand view
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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

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