Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Arrays
Message
De
14/06/2002 01:58:08
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
13/06/2002 16:44:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Arrays
Divers
Thread ID:
00668248
Message ID:
00668390
Vues:
22
>What's the best way to insert values into an array all at once?
>
>I have _array(3) and want to insert 1,2,3.
>
>I thought there was a way like _array(3) = (1,2,3) in another language so was wondering if there is something similar in Fox that I can't find.
>
>Thanks,
>Sunshine

Sunshine,
In VFP unfortunately it's not supported. You have to assign elements individually. Shortcuts comes to mind when elements fit. In your sample you're using sequential numbers like an enumeration. In that case you could use a for loop. ie:

for ix=1 to alen(_array)
_array[ix] = ix
endfor

Another shortcut is when majority of elemnents would be the same. ie: You have an array of 100,20 and all would be initialized to 0 except [1,3] and [20,5] :

_array = 0 && Initialize all to 0
_array[1,3] = 5
_array[20,5] = 15

If your data is somewhat in a cursor, table already dont forget :
copy to array ...
select ... into array ...

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform