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 >
Wrap
BASIC Source File
|
1993-01-01
|
2KB
|
62 lines
' +----------------------------------------------------------------------+
' | |
' | PBClone Copyright (c) 1990-1993 Thomas G. Hanlin III |
' | |
' +----------------------------------------------------------------------+
SUB BinSeekSt (Array$(), Elements%, Target$, CapsCount%, Posn%)
IF CapsCount% THEN
St$ = Target$
ELSE
St$ = UCASE$(Target$)
END IF
IF LEN(St$) = 0 THEN
Posn% = 0
ELSEIF Elements% = 0 THEN
Posn% = -1
ELSE
Top% = 1
Bottom% = Elements% + 1
OldPlace% = Bottom%
DO
Place% = (Top% + Bottom%) \ 2
IF CapsCount% THEN
IF Place% = OldPlace% THEN
NotThere% = -1
ELSEIF Array$(Place%) = St$ THEN
Found% = -1
ELSEIF Array$(Place%) > St$ THEN
Bottom% = Place%
ELSE
Top% = Place%
END IF
ELSE
IF Place% = OldPlace% THEN
NotThere% = -1
ELSEIF UCASE$(Array$(Place%)) = St$ THEN
Found% = -1
ELSEIF UCASE$(Array$(Place%)) > St$ THEN
Bottom% = Place%
ELSE
Top% = Place%
END IF
END IF
OldPlace% = Place%
LOOP UNTIL Found% OR NotThere%
IF NotThere% THEN
IF Elements% = UBOUND(Array$) THEN
Posn% = 0
ELSE
IF CapsCount% THEN
IF St$ > Array$(Place%) THEN Place% = Place% + 1
ELSE
IF St$ > UCASE$(Array$(Place%)) THEN Place% = Place% + 1
END IF
Posn% = -Place%
END IF
ELSE
Posn% = Place%
END IF
END IF
END SUB