Unexpected "word" parsing
Peter M. Brigham
pmbrig at gmail.com
Fri Dec 5 16:19:59 EST 2014
On Dec 5, 2014, at 1:26 PM, Peter Haworth wrote:
> word 1 of a string like myProps["cProp"] returns the whole string. Word 2
> returns"cProp"]
>
> Since cProp is enclosed in double quotes I was expecting:
>
> word 1 --> myProps[
> word 2 --> "cProp"
> word 3--> ]
>
> This is with LC 6.6.2/OSX.
Does the same in LC 5.5, but only in the messagebox.
myProps["cProp"]
word 1 -> myProps["cProp"]
word 2 -> "cProp"].
Also in the messagebox, if you ask for word 3 or word 4 or word 63 of that string, you get "cProp"] as well, so there's something screwy about using the messagebox for this. But in a button script, it returns word 1 as the whole string and word 2 as empty, which is at least consistent. However, put a space in the middle of "cProp":
myProps["c Prop"]
word 1: myProps["c
word 2: Prop"]
So in this case a string surrounded by quotation marks is not treated as one word. BUT:
myProps[ "c Prop" ]
word 1: myProps[
word 2: "c Prop"
word 3: ]
This scripting language is described as "english-like" and it's living up to its name -- every rule has its unexpected exceptions. Don't get me wrong, I love LC, but some things drive me nuts.
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
More information about the use-livecode
mailing list