Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Array - Adding lines
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00581261
Message ID:
00581283
Vues:
16
This message has been marked as the solution to the initial question of the thread.
>Hi,
>
>I'd like to create a new array called MyArray[2,3] and then, adding values like this:
>
>Declare MyArray[2,3]
>MyArray = "a", 2, .T., "b", "c", 3
>
>Is it possible? Any user function?
>
>[]'s
>
>Rodolfo Duarte
>Ribeirao Preto / SP / Brazil


May be you can start with that quick and dirty function
FUNCTION FillArray
lparam arefArray,cArrayString,cSeparator
local cTemp,i
*----------------------------
*	store values in arefArray
*	the array must be passed by ref (@arrayname)
*	and must be of the right dimension or bigger
*
*	cArrayString must be a character string
*	type conversion was made by EVAL()
*	ex: ["a", 2, .T., "b", "c", 3]
*	attention, no validations!
*
* sample call :
*   DIMENSION aTest[3,2]
*   FillArray(@atest,["a", 2, .T., {^2001/11/22}, "c", 3])
*---------------------------
IF EMPTY(cSeparator)
	cSeparator=","
ENDIF	

nElements=OCCURS(cSeparator,cArrayString)+1

FOR i=1 TO nElements
	DO CASE
		CASE i=1
			cTemp=SUBSTR(cArrayString,1,AT(cSeparator,cArrayString,i)-1)
		CASE i=nElements
			cTemp=SUBSTR(cArrayString,AT(cSeparator,cArrayString,i-1)+1)
		OTHERWISE	
			cTemp=SUBSTR(cArrayString,AT(cSeparator,cArrayString,i-1)+1,;
				AT(cSeparator,cArrayString,i)-AT(cSeparator,cArrayString,i-1)-1)
	ENDCASE
	arefArray[i]=EVAL(cTemp)
ENDFOR

RETURN
HTH :-)
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...


Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform