Here's something that I just recently noticed and started using. Probably obvious to other people but... well... I'm slow.
Anyway, in the past if I was writing a routine to scan through a string and needed it to be compatible with ascii and unicode, I'd do some compiler-if statements for incrementing the string pointer, getting the character index, etc...
However, you can use bit-shifting to be more lazy

Code: Select all
Structure CHAR
c.c
EndStructure
;-
Procedure.l FindDash(Text.s)
;
Define.l HoldIndex
;
Define.CHAR *HoldChar = @Text
;
While *HoldChar\c <> '-' And *HoldChar\c
;
*HoldChar + (1 << #PB_COMPILER_UNICODE)
;
Wend
;
HoldIndex = ((*HoldChar - @Text) >> #PB_COMPILER_UNICODE) + 1
;
ProcedureReturn HoldIndex
;
EndProcedure
;-
Debug FindDash("Please - test this string.")
;-
End
;-
..: Edit :.. Fixed a misplaced addition
