Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy to array: only 1?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00051523
Message ID:
00051613
Views:
35
>>>>>I have a code table that has Type_Code and Code fields.
>>>>>I am trying to copy to an array all the Type_Code = to "PE" and I don't know why but it only copies the first record to the array. Here is my code:
>>>>>
>>>>>use codes
>>>>>set order to Type_Code
>>>>>count for Type_Code = "PE" TO ctn
>>>>>DIMENSION aCode(ctn)
>>>>>COPY TO ARRAY aCode FIELDS Code FOR Type_Code = "PE"
>>>>>DISPLAY MEMORY LIKE Ape
>>>>>
>>>>>Thanks for your help
>>>>
>>>>Ray, remove the line "DIMENSION aCode(ctn)" That pre-sets the size of the array. Copy to Array will automatically initialize and size the array correctly IF the array doesn't exist.
>>>>
>>>>HTH
>>>>Barbara
>>>
>>>Still, why it doesn't work? I exclude the case when there's only PE record. :)
>>>
>>>Vlad
>>
>>Vlad, check out the HELP for Copy to Array.
>>
>>** From HELP
>>If you specify a one-dimensional array, the first field of a record is stored to the first element of the array, the second field is stored to the second element of the array, and so on. If the one-dimensional array has more elements than the table has fields, any remaining elements remain unchanged. If the array has fewer elements than the table has fields, any remaining fields are ignored.
>>
>>Since Ray had initialized a one-dimension array, this action took over.
>>
>>Barbara
>
>You're right. So, if you want to copy one field/record you must declare the array aArray[n,1]?
>
>Vlad

Vlad, I find it easier to not declare the array at all, then use the FIELDS and NEXT 1 clauses in the COPY TO ARRAY command. That way you only have one command.

Barbara
Barbara Paltiel, Paltiel Inc.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform