Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simple Array processing question
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01005959
Message ID:
01005987
Views:
17
Yes, ASCAN help is a little bit confusing. Here's a sample code (VFP8 or later).
DECLARE myarray[3,2]
FOR i=1 TO ALEN(myarray,1)
	myarray[i,1] = 10-i
	myarray[i,2] = 10*i
ENDFOR

lnSite = 20

lnRow = ASCAN(myarray, lnSite, -1, -1, 2, 8)
IF lnRow > 0
	? myarray[lnROw,1]
ENDIF
* 2-D and 1-D reference to the same element.
? myarray[2,2], myarray[4]
Yes, it's true that you can reference items in an 2-D array with 1-D notation but you should only do that if you have to.

>
>ASCAN(ArrayName, eExpression [, nStartElement [, nElementsSearched [, nSearchColumn [, nFlags ]]]])
>
>I am confused between elements and rows. When I use the ASCAN, it seems that nStartElement and nElementsSearched are really the row numbers and not element numbers.
>
>Also, the help for ASUBSCRIPT says "Each of these commands stores the character string INVOICE to the same array element:" Is this true? Isn't gaMyArray (4) the same as gaMyArray(2,2)?
>
>
>STORE 'INVOICE' TO gaMyArray(2, 1)
>STORE 'INVOICE' TO gaMyArray(4)
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform