a$ = "Hello"
b$ = "ol"
i% = sinstr(a$, b$)
'-------------------------------------------------------------------------------
' Function: sinstr% (str1$, set1$)
' Finds position in str1$ of first occurrence of any of the characters in set1$
'
'------------------------------------------------
' References:
' https://www.qb64.org/wiki/MEM
' http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index_topic_5967-30/
'------------------------------------------------
'Find the first character in x$ of any of the characters in y$.
' copy variable strings to fixed length strings
' add terminating null.
str1$
1024 = str1$
+ CHR$(0)
find_first_of%& = strpbrk%&(str1$1024, set1$)
'Strings are unit-based in QB64, so we must add 1.
find_first_of%&
= find_first_of%&
- _OFFSET(str1$
1024) + 1 m
= _MEM(find_first_of%&
)
'On 64 bit OSes, an OFFSET is 8 bytes in size.
sinstr% = temp&&
'However, on 32 bit OSes, an OFFSET is only 4 bytes.
sinstr% = temp&