Re: Kat's 8bit sequences
- Posted by Jim Brown <jbrown105 at linuxbuddhi?t.n?t> Jun 01, 2008
- 750 views
Kat wrote: > w32engine has this stuff, among tons of other stuff... > Def &= {{0,"StrStrA",11,{pointer_,pointer_},pointer_}} > global function StrStrA(object p) return f_(1816,p) end function <other redundant stuff snipped> Ugh. That's ugly. Ok, here is your match function for C strings, using StrStrA: constant LIB = open_dll("shlwapi.dll") --constant LIB = open_dll("shell32.dll") constant StrStrA = define_c_func(LIB, "StrStrA", {C_POINTER, C_POINTER}, C_POINTER) global function match(atom a, atom b) atom ret ret = c_func(StrStrA, {a, b}) if ret != NULL then ret = ret - a else ret = -1 end if return ret end function > > So,, you are going to tell me to google it all, right? Yes, because then you'll see your message on Google. :D Here is a (signifcantly slower) implementation in pure Eu: global function match(atom a, atom b) for i = 0 to strlen(a) do for j = 0 to strlen(b) do if slice(a,i+j) != slice(b,j) then exit elsif j = strlen(b) then return i else --continue end if end for end for return -1 end function > > Kat