home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / PBC22B.ZIP / PBC$BAS.ZIP / BINSEKST.BAS < prev    next >
BASIC Source File  |  1993-01-01  |  2KB  |  62 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |        PBClone  Copyright (c) 1990-1993  Thomas G. Hanlin III        |
  4. '   |                                                                      |
  5. '   +----------------------------------------------------------------------+
  6.  
  7. SUB BinSeekSt (Array$(), Elements%, Target$, CapsCount%, Posn%)
  8.    IF CapsCount% THEN
  9.       St$ = Target$
  10.    ELSE
  11.       St$ = UCASE$(Target$)
  12.    END IF
  13.    IF LEN(St$) = 0 THEN
  14.       Posn% = 0
  15.    ELSEIF Elements% = 0 THEN
  16.       Posn% = -1
  17.    ELSE
  18.       Top% = 1
  19.       Bottom% = Elements% + 1
  20.       OldPlace% = Bottom%
  21.       DO
  22.          Place% = (Top% + Bottom%) \ 2
  23.          IF CapsCount% THEN
  24.             IF Place% = OldPlace% THEN
  25.                NotThere% = -1
  26.             ELSEIF Array$(Place%) = St$ THEN
  27.                Found% = -1
  28.             ELSEIF Array$(Place%) > St$ THEN
  29.                Bottom% = Place%
  30.             ELSE
  31.                Top% = Place%
  32.             END IF
  33.          ELSE
  34.             IF Place% = OldPlace% THEN
  35.                NotThere% = -1
  36.             ELSEIF UCASE$(Array$(Place%)) = St$ THEN
  37.                Found% = -1
  38.             ELSEIF UCASE$(Array$(Place%)) > St$ THEN
  39.                Bottom% = Place%
  40.             ELSE
  41.                Top% = Place%
  42.             END IF
  43.          END IF
  44.          OldPlace% = Place%
  45.       LOOP UNTIL Found% OR NotThere%
  46.       IF NotThere% THEN
  47.          IF Elements% = UBOUND(Array$) THEN
  48.             Posn% = 0
  49.          ELSE
  50.             IF CapsCount% THEN
  51.                IF St$ > Array$(Place%) THEN Place% = Place% + 1
  52.             ELSE
  53.                IF St$ > UCASE$(Array$(Place%)) THEN Place% = Place% + 1
  54.             END IF
  55.             Posn% = -Place%
  56.          END IF
  57.       ELSE
  58.          Posn% = Place%
  59.       END IF
  60.    END IF
  61. END SUB
  62.