Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamically Sizing Arrays
Message
 
To
31/05/2001 18:11:59
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00513486
Message ID:
00514038
Views:
12
Keith,

>>You're saying that a cursor would be more eficient than an
array for 50 elements?

No. But being able to reference (descriptively named) fields in a cursor can be easier to read than row/column references to an array. And because so much of VFP's table handling is buffered, there may not be much of a performance hit.

I'm not espousing either approach (not denegrating either). Sometimes I'll use a cursor because an array would be substantially less legible. Just something to think about.

BTW, regarding your original question, no, there's no significant performance hit involved in successively redimensioning an array, especially given your previous example.

Covering all the bases, if there's a delimiter in the string you're going to parse, OCCURS() is a great way to predimension the array.
m.lnArr = OCCURS(",", m.lcStr) + 1
DIMENSION laParse[m.lnArr]

FOR m.i = 1 TO m.lnArr -1
   laParse[m.i] = LEFT(m.lcStr, AT(",", m.lcStr) -1)
   m.lcStr = SUBSTR(m.lcStr, AT(",", m.lcStr) +1)
NEXT

laParse[m.lnArr] = m.lcStr
Regards,
Thom C.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform