Article ID: 104053
Article Last Modified on 3/10/2005
SET DEFAULT TO <path to FoxPro TUTORIAL directory>
USE customer
COPY TO ARRAY arr FIELDS state FOR state = "CA"
* arr has 123 elements, all of which are "CA".
COPY TO ARRAY arr FIELDS state FOR state = "AK"
* arr still has 123 elements, but issuing the command
* DISPLAYMEMORY LIKE arr will show that only the first
* element of arr is "AK"; the rest are "CA".
Use this code for Visual FoxPro:USE HOME(2)+"data\customer"
COPY TO ARRAY arr FIELDS country FOR country = "USA"
* arr has 13 elements, all of which are "USA".
DISPLAY MEMORY LIKE arr TO FILE arr1.txt noconsole
**RELEASE arr && release array arr and new aray is created.
COPY TO ARRAY arr FIELDS country FOR country = "Brazil"
* arr still has 13 elements, but issuing the command
* DISPLAYMEMORY LIKE arr shows that only the first
* 9 elements of arr is "Brazil"; the rest are "USA".
DISPLAY MEMORY LIKE arr TO FILE arr2.txt noconsole
MODIFY COMMAND arr1.txt NOEDIT nowait
MODIFY COMMAND arr2.txt NOEDIT NOWAIT
NOTE: If the second COPY TO ARRAY command returns a smaller number
of elements than those existing in the array, only that number of
elements will be overwritten; the others will retain their former
value.
SELECT cno FROM customer INTO array arr WHERE state = "CA"
* arr now has 123 elements, all of which are "CA".
SELECT cno FROM customer INTO ARRAY arr WHERE cno = "AK"
* ALEN(arr) =1; the value is "AK".Use this code for Visual FoxPro:USE HOME(2)+"data\customer"
SELECT country FROM customer INTO array arr WHERE country = "USA"
* arr now has 13 elements, all of which are "USA".
? arr(1) && the value is "USA".
? ALEN(arr) && 13
SELECT country FROM customer INTO ARRAY arr WHERE country = "Brazil"
* arr now has 9 elements, all of which are "USA".
?Arr(1) && the value is "Brazil".
?ALEN(arr) && 9Additional query words: VFoxWin FoxDos FoxWin dimension declare
Keywords: KB104053