Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Search by from - to
Message
Information générale
Forum:
Level Extreme
Catégorie:
Autre
Divers
Thread ID:
01136364
Message ID:
01142079
Vues:
9
>Hi Naomi,
>
>>>I recall that Christof Wollenhaupt once wrote me an algorithm of parsing (?) save memvar / restore from memvar.
>
>Actually, i did some research in 1999 about the structure of MEM files because we were constantly having corrupted MEM files. Can't find my test code from back then, but the following code might get you started:
>
>*========================================================================================
>* Reads a mem file
>*========================================================================================
>LParameter tcMEM
>
>	Local lcMEM
>	lcMEM = FileToStr(m.tcMEM)
>	Do while not Empty(m.lcMEM)
>		ReadPart( @lcMEM )
>		If m.lcMEM == Chr(0x1A)
>			Exit
>		EndIf
>	EndDo
>
>
>*========================================================================================
>* Read next variable from MEM file
>*========================================================================================
>Procedure ReadPart( rcMem )
>
>	Local lcName, lcType, lnLen, lnDecimals, lnTotal, luData
>	lcName = Chrtran(Left(m.rcMem,10),Chr(0),"")
>	lcType = Substr(m.rcMem,12,1)
>	lnLen = CToBin(Substr(m.rcMem,17,1),"RS")
>	lnDecimals = CToBin(Substr(m.rcMem,18,1),"RS")
>	
>	Do case
>
>	*--------------------------------------------------------------------------------------
>	* Character variables with a name of 10 characters or less and a content of 255
>	* characters or less.
>	*--------------------------------------------------------------------------------------
>	Case m.lcType == "C"
>		luData = Substr(m.rcMem,33,m.lnLen-1)
>		lnTotal = 32+m.lnLen
>
>	*--------------------------------------------------------------------------------------
>	* Characters with a name longer than 10 characters but 255 or less characters of
>	* content.
>	*--------------------------------------------------------------------------------------
>	Case m.lcType == "c"
>		Local lnVarLength
>		lnVarLength = CToBin(Substr(m.rcMem,33,2),"RS")
>		lcName = Substr(m.rcMem,35,m.lnVarLength)
>		luData = Substr(m.rcMem,35+m.lnVarLength,m.lnLen-1)
>		lnTotal = 34+m.lnVarLength+m.lnLen
>	
>	*--------------------------------------------------------------------------------------
>	* Numeric values
>	*--------------------------------------------------------------------------------------
>	Case m.lcType == "N"
>		Local lnDouble, lcString
>		lnDouble = 0
>		lcString = Substr(m.rcMem,33,8)
>		Declare RtlMoveMemory in Win32API as __CharToDouble Double@, String@, Integer
>		__CharToDouble( @lnDouble, @lcString, 8 )
>		lnDouble = m.lnDouble - 0.0000000000000000000
>		luData = Round(m.lnDouble,m.lnDecimals)
>		lnTotal = 32+8
>	
>	Otherwise
>		lnTotal = 32 + m.lnLen
>	endcase
>		
>	*--------------------------------------------------------------------------------------
>	* Remove entry
>	*--------------------------------------------------------------------------------------
>	rcMem = Substr(m.rcMem,m.lnTotal+1)
>	
>	*--------------------------------------------------------------------------------------
>	* Display variable
>	*--------------------------------------------------------------------------------------
>	? m.lcName + " "+m.lcType+"("+Transform(m.lnLen)+","+Transform(m.lnDecimals)+"): ", ;
>		m.luData
>	
>EndProc
>
Thanks a lot, Christof. Now I just have to remember who asked the question prompting me to search <g> AFAIK it was Mark Goldin, but I may be mistaken...
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform