Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamically Sizing Arrays
Message
From
01/06/2001 15:48:39
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00513486
Message ID:
00514006
Views:
17
>Keith,
>
>No one has mentioned acopy(), that seems very useful here.
>Let us suppose you want to add rows from current cursor to existing array A1.
>Then you can do it as follows:
>*-----------------
>ln=alen(a1)
>copy fields for &condition to array ajoin
>*redimension array A1 to make room for ajohn
>dime a1[alen(a1,1)+_tally, alen(a1)/alen(a1,1))
>* concatenate two arrays
>acopy(ajohn, a1, 1, alen(ajoin),ln+1)
>*--------------------------------
>
>Yuri

Thanks for the reply Yuri, but ACOPY() isn't really
a solution here. In order to use ACOPY() you have
to have an array to begin with. The situation is
that I have a string with an unknown number of items
that I need to store in an array. I was questioning
the speed an reliability of redimensioning an array
each time I need to add a new element to it.

Kinda like:
SCAN
   lcToken = GetToken( InLine)
   IF NOT EMPTY( lcToken)
      lnTokenCnt = lnTokenCnt + 1
      DIMENSION laTokens[ lnTokenCnt]
      laTokens[ lnTokenCnt] = lcToken
   ENDIF
ENDSCAN
In this (hypothetical) situation, you don't know how
many lines have tokens, but you want to store the ones
you find in an array. This is roughly what I am trying
to accomplish.

...kt
Previous
Reply
Map
View

Click here to load this message in the networking platform