Offset() and wordOffset() odd behavior

Mark Smith mark at maseurope.net
Sun Mar 26 14:47:18 EST 2006


Bob, I think what's happening is that wordOffset is finding the  
string "to" in the word "store".

If you put "set the wholeMatches to true" in your handler, it should  
behave as you wish.

Alternatlively

wordOffset{" to ",fLine) should also work.


Best,

Mark

On 26 Mar 2006, at 05:51, Robert Sneidar wrote:

> Maybe I am missing something. Observe the following code:
>
> put ("store " & quote & "1234" & quote & " to mbob1, mbob2, mbob3")  
> into fline
> -- which produces a string "store "1234" to mbob1, mbob2, mbob3"
> -- Notice the embedded quotes
> put wordOffset("to", fline) -- returns 1, as in the first word  
> after the last embedded quote
>
> Apparently the quotes are resetting the counter for the function.  
> My problem is, I am writing a script that can convert some basic  
> Foxpro source code to Revolution Script. It's perfectly acceptable  
> in Foxpro to say:
>
> store "1234" to mbob1, mbob2, mbob3
>
> and Foxpro programmers do it early and often to initialize  
> variables. I am trying to end up with:
>
> put "1234" into mbob1
> put "1234" into mbob2
> put "1234" into mbob3
>
> Trouble is, I do not know what may come before the word "to". It  
> could be any construct. Since Revolution does not support putting  
> something into multiple variables, this becomes problematic to  
> convert. I suppose I could hack a way around it. I think I will end  
> up using offset() instead to avoid this. It's just a curious thing  
> that Revolution will treat fline as one whole string, but the  
> function seems to burp when it encounters embedded quotes.
>
> Not complaining, just observing.
>
> Bob Sneidar
> IT Manager
> Logos Management
> Calvary Chapel CM
>
> ps. Just an update. Offset() returns 2 when I use Offset("to",  
> fline) BUT... here we go kiddies... Offset(" to ", fline) returns  
> the correct value of 13! Hah! I guess you could say the function is  
> blowing chunks! (A little [very little] programmers humor). Notice  
> the spaces before and after "to". What an odd function! 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list