BUG: COPY TO ARRAY Behaves Differently from dBASE

Last reviewed: May 6, 1997
Article ID: Q130524
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a

SYMPTOMS

Using the command COPY TO ARRAY <array name> FIELDS <field list> where one of the fields in the field list is a calculated expression generates one of the following errors:

  • Not a character expression.

    -or-

  • Command contains unrecognized phrase/keyword.

CAUSE

Calculated expressions are not evaluated in the COPY TO ARRAY command.

NOTE: This is a common practice among dBASE programmers and will cause legacy code to break.

RESOLUTION

To resolve this error message do one of the following:

  • Modify the structure of the source table to accommodate result data from calculated expressions.

    -or-

  • Create the array using the SQL syntax. This syntax permits calculated expressions to some degree. For example, if you need a four-element array that contains data from three specific fields in your table in addition to a calculated expression, your code would look like this:

    SELECT product, units, cost, (cost*unit) ;

          FROM products ;
          INTO ARRAY aTemp
    

    Here product, units, and cost are fields from a table called products and (cost*units) is a calculated expression.

    -or-

  • Create the array with an extra element and STORE the results of the calculation in the corresponding array element by using a FOR loop. For example, if you need a four-element array with 10 rows and the last element in the array should contain the calculated expression, your code would look like this:

    DIMENSION aTemp[5,10] FOR i = 1 TO 10 STEP 1

          STORE (i + 1) TO aTemp[5,i]
    
    ENDFOR

    Here (i + 1) is the calculated expression.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Keywords : buglist3.00 buglist3.00b buglist5.00 kb3rdparty vfpbug5.0a kbbuglist
Version : 3.0 3.0b 5.0 5.0a
Platform : WINDOWS
Issue type : kbbug


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: May 6, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.