home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1995 November / PCPRO_NOV95.ISO / code / db / listfind.txt < prev    next >
Encoding:
Text File  |  1995-09-08  |  828 b   |  30 lines

  1. LParameters tcItemValue, tlCaseSensitive
  2.  
  3. Local lnItem    && a list-item counter
  4.  
  5. * We only want to accept character-type search strings
  6. if type("tcItemValue") <> "C"
  7.     tcItemValue = ""
  8. endif
  9.  
  10. * We'll have two separate loops for case sensitivity and case insensitivity
  11. * for performance reasons
  12. if tlCaseSensitive
  13.     * Loop through the list items, doing case sensitive matching
  14.     for lnItem = 1 to this.ListCount
  15.         if this.List(lnItem) = tcItemValue
  16.             exit
  17.         endif
  18.     endfor
  19. else
  20.     * Loop through the list items, doing case insensitive matching
  21.     for lnItem = 1 to this.ListCount
  22.         if lower(this.List(lnItem)) = lower(trim(tcItemValue))
  23.             exit
  24.         endif
  25.     endfor
  26. endif
  27.  
  28. * Return the item index at which the string was found, or 0 if no match
  29. return iif(lnItem > this.ListCount or empty(tcItemValue), 0, lnItem)
  30.