ASCAN( ) Function Example

The following example creates and fills an array with company names, and then uses ASCAN( ) to search for a particular company name. If the company name is found, it is removed from the array.

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE customer     && Open customer table
SELECT company FROM customer ;
   WHERE country = 'UK' ;
   INTO ARRAY gaCompanies
gnCount = _TALLY
gcName = 'Seven Seas Imports'
CLEAR
DISPLAY MEMORY LIKE gaCompanies*
gnPos = ASCAN(gaCompanies, gcName) && Search for company
IF gnPos != 0
   *** Company found, remove it from the array ***
   = ADEL(gaCompanies, gnPos)
   gnCount = gnCount - 1
ENDIF
DISPLAY MEMORY LIKE gaCompanies