PRB: COPY TO ARRAY "<Array> Is Not An Array" Error

Last reviewed: April 17, 1995
Article 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 "'<array name>' is not an array" error message.

CAUSE

The error "'<array name>' is not an array" 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 = "AA"

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 "AA"
   IF FOUND()
       COPY TO ARRAY MYARRAY FOR STATE = "AA"
   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 "0 records copied" 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 = "NY"

   Message "0 records copied"

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.

MORE INFORMATION

Example 1

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

Example 2

   USE C:\FOXPRO2\TUTORIAL\CUSTOMER.DBF ORDER state
   SEEK "NY"
   COPY TO ARRAY myarray WHILE state = "NY"

REFERENCES

"Microsoft FoxPro Commands & Functions" Page C3-243


Additional reference words: FoxDos 2.00
KBCategory: kbprg kbprb
KBSubcategory:


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.