Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing an array in Memo field
Message
De
10/08/2012 09:23:35
 
 
À
10/08/2012 09:03:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01550185
Message ID:
01550284
Vues:
53
>>>>>Hi,
>>>>>
>>>>>I have a VFP table with a Memo field which holds a couple of variables and a two dimensional numeric array (populated by SAVE TO xxx ALL LIKE Flash*), Is the binary format in which these are stored known to anyone?
>>>>>
>>>>>I haven't worked with VFP for quite a while but cannot recall, or find on the web, anything on this......
>>>>>
>>>>>TIA,
>>>>>Viv
>>>>
>>>>
>>>>Yes, Viv - see (old) download#15242 - should get you started
>>>
>>>Thx. Haven't a chance to look at it yet but sounds promising.....
>>
>>Sounds like an interesting thing to do - shout if you need any help
>
>Boy have I forgotten VFP ! Where does CharToBin() come from ?

I was thinking to have a go at it - but I'm struggling to write a class - vfpvariable

Going from the untyped world to the typed world is a challenge here

Possibilities

(1) use an enum to indicate the type and have one field per type
enum ValueType = ...

ValueLogical
ValueNumeric
...

(2) use an object as value

But either approach is a headache (tests, too much code) when it comes to assigne the value

Perhaps Dynamic ?



This code is 10 year old -


If your vfp version does not support ctobin(m.s, '4rs'), then use the commented line below
function CharToBin(s)
	
	do case
	case len(m.s) = 4
		return ctobin(m.s, '4rs')
		&&return asc(m.s)  + bitlshift(asc(substr(m.s,2,1)),8) + bitlshift(asc(substr(m.s,3,1)),16) + bitlshift(asc(substr(m.s,4,1)),24)
	
	case len(m.s) = 2
		return ctobin(m.s, '2rs')
		&& return asc(m.s)  + bitlshift(asc(substr(m.s,2,1)),8)
		
	otherwise
		assert FALSE
		return FALSE
	
	endcase
endfunc
*----------------------------------------------------------------------------
function BinToChar(x)
	
	return bintoc(m.x, '4rs')
	&& return	chr(bitand(m.x, 0xff)) + ;
			chr(bitand(bitrshift(m.x,  8), 0xff)) + ;
			chr(bitand(bitrshift(m.x, 16), 0xff)) + ;
			chr(bitand(bitrshift(m.x, 24), 0xff)) ;
				

endfunc
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform