Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to dimension an array of type array
Message
De
12/05/2007 10:23:33
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
12/05/2007 09:52:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01224954
Message ID:
01224958
Vues:
12
>hi,
>I am employed at an application where I have to do a schedule of class for the courses of a college.
>
>I want to know, since in vfp can define a array, which it can contain mas of an information in every position (x, y)
>As for ej. in lengueje C, I will can define an estruct with 3 fields code, name, telephone and after define a array of this type of information.
>Then will can to index array (x, y) .nombre ='jose '

To declare an array of 5 x 6 elements, the traditional command is:
dimension MyArray(5, 6)
But better just combine it with the LOCAL declaration:
local MyArray(5, 6)
To access an element:
MyArray(3, 2) = "José"
Note that in Visual FoxPro, all variables, and array elements, are of type "varchar" (as it is called in some other languages), i.e., you can mix types freely.

If you want to have a "struct" in every array element, well, Visual FoxPro doesn't really have the equivalent of a struct. However, you can do much of the same if you use objects. For example, if you have a class called cPerson, with properties for name, date born, etc., here is a quick sample code to create an array of objects based on this class (I only used a single array element in this sample):
set classlib to samples
dimension MyArray(5,5)
MyArray(1,2) = CreateObject("cPerson")
with MyArray(1,2)
	.FirstName = "Hilmar"
	.LastName = "Zonneveld"
	? "Your name is " + .FirstName
endwith
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform