If a sting isn't modified it should be passed in by reference but so often strings are needlessly passed by value just to maintain syntactic consistency. So using the prototype trick is actually very handy. It makes it easy for users.
Code: Select all
Prototype StrCmp(a.p-unicode,b.p-unicode) ;convert a string input to a pointer
Structure aUnicode
c.u[0]
EndStructure
Procedure _StrCmp(*a.aUnicode,*b.aUnicode)
Protected a,b
While *a\c[ct] = *b\c[ct]
ct+1
a = *a\c[ct]
b = *b\c[ct]
If (a = 0 And b = 0)
ProcedureReturn 1
ElseIf (a = 0 Or b = 0)
ProcedureReturn 0
EndIf
Wend
EndProcedure
Global StrCmp.StrCmp = @_StrCmp()
Global sa.s = "helloworld"
Global sb.s = sa
Global sc.s = "helloPB"
Debug StrCmp(sa,sb)
Debug StrCmp(sa,sc)