Category : BASIC Source Code
Archive   : QB_CODE.ZIP
Filename : BSRCHLNG.BAS

 
Output of file : BSRCHLNG.BAS contained in archive : QB_CODE.ZIP
'
' BSRCHLNG.BAS - For the QuickBASIC Toolbox
' Long Integer Binary Search Function
'

'
' $INCLUDE: 'TOOLBOX.BI'
'

DEFINT A-Z

FUNCTION BSEARCHLNG (ARRAY&(), SKEY&)
LOWER = LBOUND(ARRAY&, 1)
UPPER = UBOUND(ARRAY&, 1)
WHILE LOWER <= UPPER
MIDDLE = (LOWER + UPPER) \ 2
SELECT CASE SKEY&
CASE ARRAY&(MIDDLE)
BSEARCHLNG = MIDDLE
EXIT FUNCTION
CASE IS < ARRAY&(MIDDLE)
UPPER = MIDDLE - 1
CASE ELSE
LOWER = MIDDLE + 1
END SELECT
WEND
BSEARCHLNG = LBOUND(ARRAY&, 1) - 1
END FUNCTION



  3 Responses to “Category : BASIC Source Code
Archive   : QB_CODE.ZIP
Filename : BSRCHLNG.BAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/