Microsoft KB Archive/93332

{| = PRB: COPY TO ARRAY &quot; Is Not An Array&quot; Error =
 * width="100%"|

ID: Q93332

The information in this article applies to:


 * Microsoft FoxPro for MS-DOS, version 2.0

SYMPTOMS
The COPY TO ARRAY command returns an &quot;' ' is not an array&quot; error message.

CAUSE
The error &quot;' ' is not an array&quot; occurs when you are using the COPY TO ARRAY command if none of the records meet the FOR condition criteria. For example, the error occurs if you issue the following command

USE C:\FOXPRO\TUTORIAL\CUSTOMER COPY TO ARRAY FOR STATE = &quot;AA&quot; because none of the records in the database match the FOR condition.

RESOLUTION
If you use the COPY TO ARRAY FOR command, verify that the FOR condition is met prior to issuing the command. You can use the SEEK command to accomplish this. For example:

USE C:\FOXPRO\TUTORIAL\CUSTOMER SET ORDER TO TAG STATE SEEK &quot;AA&quot; IF FOUND COPY TO ARRAY MYARRAY FOR STATE = &quot;AA&quot; ENDIF The COPY TO ARRAY command has a WHILE clause, which can be used to copy the records to the array if the record pointer is positioned on a record that does meet the WHILE condition. If you issue the COPY TO ARRAY WHILE command and the record pointer is not on a record that meets the WHILE condition, the message &quot;0 records copied&quot; is displayed. To reproduce this condition, enter the following commands in the Command window:

USE C:\FOXPRO2\TUTORIAL\CUSTOMER.DBF ORDER state COPY TO ARRAY myarray WHILE state = &quot;NY&quot;

Message &quot;0 records copied&quot; To avoid this error, use the SEEK command to position the record pointer on a record that meets the WHILE condition before creating the array. The database must be ordered on the field that is tested in the WHILE clause. It may also be necessary to test for the case in which no records meet the WHILE condition.

Example 1
USE C:\FOXPRO2\TUTORIAL\CUSTOMER.DBF ORDER state IF SEEK (&quot;NY&quot;) COPY TO ARRAY myarray WHILE state = &quot;NY&quot; ELSE WAIT WINDOW &quot;No matching records&quot; ENDIF

Example 2
USE C:\FOXPRO2\TUTORIAL\CUSTOMER.DBF ORDER state SEEK &quot;NY&quot; COPY TO ARRAY myarray WHILE state = &quot;NY&quot;