Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AScan on a specific column?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00005501
Message ID:
00005622
Views:
59
>Anybody know if there is API routine that will do the equivalent of ASCAN, but will let you specify a given column to scan and return the row number of the matching cell? The problem with ASCAN is that it scans the entire array. If the information across columns is not unique, ASCAN is pretty useless! Doing the search in a FOR loop to access Row,Col is pretty slow. I'm looking for a fast alternative. Thanks!



Mark,
I have written a function which goes pretty fast.
I hope I hope this gets you a little more speed and that
the message format is not too hard to read!

(Sorin@suzy you could learn from this too.)

************************************************************
* Author............: Christopher Lanski
* Parameter List....: Name of the array, what to look for, column number

FUNCTION ASeek(tcAName, tuSeekStr, tnColumn)

LOCAL nRetVal, nElementNo

IF TYPE("tnColumn") # "N"
tnColumn = 1
ENDIF

IF TYPE(tcAName +"[1,1]") = "U"
WAIT WINDOW "Name passed to aseek is not an array"
RETURN -1
ENDIF

nElementNo = 1

DO WHILE .T.
nRetVal = ASCAN((tcAName),tuSeekStr,nElementNo)

IF nRetVal = 0
EXIT
ELSE
IF ASUBSCRIPT((tcAName),nRetVal,2) = tnColumn
nRetVal = ASUBSCRIPT((tcAName),nRetVal,1)
EXIT
ELSE
nElementNo = nRetVal +1
ENDIF
ENDIF
ENDDO

RETURN nRetVal
Chris
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform