Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Day 024: LCASE$
#7
So brainstorming a bit here... which reminds me, buy Flex Tape...

The QB64 IDE keeps your entire code as a string, if I remember correctly. So I wanted to see what would be the faster way to search our code with LCASE$()

Code: (Select All)
' Method #1
a$ = "Dog Cat Rabbit Moose Elephant Bear Tiger Fish "
search$ = "moose"

IF INSTR(LCASE$(a$), search$) THEN PRINT "Found: "; search$ ELSE PRINT "No search results.."

' Method #2
DO
    j% = INSTR(seed%, a$, " ")
    IF j% = 0 THEN EXIT DO
    IF LCASE$(MID$(a$, seed%, j% - seed%)) = search$ THEN EXIT DO
    REM PRINT "|" + LCASE$(MID$(a$, seed%, j% - seed%)) + "|", search$ ' Show parsing...
    seed% = j% + 1
LOOP

IF j% THEN PRINT "Found: "; search$ ELSE PRINT "No search results.."

So I did some speed tests and it appears Method #1 is the winner by a factor of 5 or more.

Waiting for Steve to post... Why Method #3, of course!... and give the IDE method or somethong he came up with. (Spelling mistake intentional).

Pete
Reply


Messages In This Thread
Day 024: LCASE$ - by Pete - 12-04-2022, 05:17 AM
RE: Day 024: LCASE$ - by mnrvovrfc - 12-04-2022, 12:01 PM
RE: Day 024: LCASE$ - by luke - 12-04-2022, 01:25 PM
RE: Day 024: LCASE$ - by SMcNeill - 12-04-2022, 01:48 PM
RE: Day 024: LCASE$ - by mnrvovrfc - 12-04-2022, 05:57 PM
RE: Day 024: LCASE$ - by SMcNeill - 12-04-2022, 10:47 PM
RE: Day 024: LCASE$ - by Pete - 12-04-2022, 04:10 PM
RE: Day 024: LCASE$ - by Pete - 12-04-2022, 06:47 PM
RE: Day 024: LCASE$ - by SMcNeill - 12-04-2022, 11:16 PM
RE: Day 024: LCASE$ - by Pete - 12-05-2022, 12:59 AM
RE: Day 024: LCASE$ - by luke - 12-05-2022, 07:30 AM
RE: Day 024: LCASE$ - by mnrvovrfc - 12-05-2022, 08:24 AM
RE: Day 024: LCASE$ - by Pete - 12-05-2022, 10:38 AM



Users browsing this thread: 3 Guest(s)