Version 1 October 15 features the new ultrafast variant of Instr_():
Instr_, Rinstr, wInstr, InstrOr
Print "The current drive is ", Left$(ThisExe$, Instr_(ThisExe$, "\")-1)
mov pos, Instr_(1, L$(n), "equ", 1+4) ; 1=start pos, 1=case-insensitive + 4=full word
Rem - returns relative pos in edx, absolute in eax
- if no match is found, zero is returned in edx, and eax points to the start of the 'haystack'; same if 'needle' is empty
- six syntax variants allowed:
A: has startpos: Instr_(1, "Test", "Te", 2) ; 4 args
B: no startpos: Instr_("Test", "Te", 2) ; 3 args, last one immediate = mode
C: has startpos: Instr_(1, "Test", "Te") ; 3 args, last one not immediate
D: no startpos: Instr_("Test", "Te") ; 2 args
E: test several patterns: InstrOr("Test", "Te" or "st", 1) ; 3 args (startpos is 1)
F: extra fast mode: Instr_(FAST, My$(ecx), "Hello", 0) ; 4 args, no startpos, modes 0+2 only
- case & mode (bitwise flag):
0=case-sensitive, +1=insensitive, +2=intellisense (Name=name),
+4=full word search, +8=include start of line in text block search
Note: full word search returns failure for chars above ASCII 64 to the left or right
Example: Nostructfoundhere, this123struct456isfound, this@struct, too
The FAST option is about twice as fast as CRT strstr, and three times
as fast when used with string arrays;
using FAST, binary search in haystacks containing zeros is possible by
assigning the buffer size to edx:
mov edx, LastFileSize ; any info on length of buffer can be used with edx
Print Str$("Pos in executable: %i", Instr_(FAST, esi, "kernel32", 2 or 64) ; 2=case-insensitive, 64=len in edx
- wRinstr is available but only as wRinstr(src, pattern) with a one-byte pattern (e.g. "\")