Page 2 of 3
Re: viewing invisible characters in variable watcher
Posted: Tue Sep 23, 2014 3:22 am
by mattmaier
dunbarx wrote:
You cannot split by "don'tBePrecipitous"
Yeah, LiveCode is interpreting that as a variable and throws out an error. Cuz it's not punctuation, maybe?
Re: viewing invisible characters in variable watcher
Posted: Tue Sep 23, 2014 5:13 am
by dunbarx
Now I am confused.
As Jacque pointed out, LC will throw an error if you try to split data by the string ", " (comma-space). It will compile, but not run. When you split by comma alone, you get the array:
where the element associated with each key either has a space or not, depending on whether there was a space in each "item" of the original comma delimited text. In this instance, since you are simply splitting data with a single delimiter, the keys will be numerically and sequentially assigned to each element. Placing that two char string in a variable throws the same error. LC would not care whether the literal or the variable was used.
How did you get this to run?
The closest I can get to what you reported would be this:
split testString by space and comma
But even that is not quite what you saw, and anyway goes back to ordinary syntax, that is, two separate delimiters, separated into distinct tokens by the use of "and".
Craig
Re: viewing invisible characters in variable watcher
Posted: Tue Sep 23, 2014 5:19 am
by dunbarx
You cannot split by "don'tBePrecipitous"
Yeah, LiveCode is interpreting that as a variable and throws out an error. Cuz it's not punctuation, maybe?
You have to learn not to take me too literally.
Anyway, go back to the real thread. Something is going on there...
Craig
Re: viewing invisible characters in variable watcher
Posted: Tue Sep 23, 2014 5:47 am
by Simon
You have to learn not to take me too literally.
I was also concerned that was the case...
Simon
Re: viewing invisible characters in variable watcher
Posted: Tue Sep 23, 2014 6:48 pm
by jacque
mattmaier wrote:I thought I understood what you meant, but it looks like splitting by ", " works exactly like it should.
Well, there's definitely something odd going on. Either multiple characters are an undocumented feature or there's a bug in the engine. It does appear that at least in LC 7.0 (where I'm testing this) you can indeed split by multiple characters.
That doesn't explain why your original script gets artificially-inserted carriage returns when using a trailing space in the split command, and it doesn't with only a single comma. So there's some glitch somewhere but I can't quite pin down what it is.
Someone who can read the LC source code might be able to find it, I'm not that talented. But I'm definitely curious.
Re: viewing invisible characters in variable watcher
Posted: Tue Sep 23, 2014 6:50 pm
by dunbarx
In 6.6.2 the engine throws an error with more than one char as a delimiter.
Craig
Re: viewing invisible characters in variable watcher
Posted: Tue Sep 23, 2014 7:03 pm
by jacque
dunbarx wrote:In 6.6.2 the engine throws an error with more than one char as a delimiter.
Ah yes, so I'm not completely senile yet. Mattmaier must be using 7.0. I wonder if this is a side effect of the Unicode implementation where 2-byte characters are the norm, because I just tried to split by 3 characters ("abc") and I get the expected compilation error. The unusual result (spurious carriage returns) may also be related.
Re: viewing invisible characters in variable watcher
Posted: Tue Sep 23, 2014 7:31 pm
by dunbarx
Jacque.
OOOH.
That was incisive, that two-byte unicode connect. Mattmaier, Is it so?
Surely Monte or Mark W. or even Mark W. will chime in?
Craig
Re: viewing invisible characters in variable watcher
Posted: Tue Sep 23, 2014 9:04 pm
by jacque
I'm not sure if it's a bug or not, but I reported it anyway. RR can close it out if I'm wrong, but my gut says it isn't supposed to do that.
Re: viewing invisible characters in variable watcher
Posted: Tue Sep 23, 2014 10:25 pm
by dunbarx
The way that arrays are created, in that they are a set of keys with one or more levels of associated elements. requires that these parts be delimited explicitly. You can create multilevel arrays directly:
Code: Select all
put "foo" into myArray[a][b][c][d][e]
But the 'split" command only goes down one level, a key and an associated element. Would it be a feature to be able to split further:
Code: Select all
split "tkey,element1,element2,element3" by comma and comma and comma
or
split "tkey,element1,element2,element3" by ",,,"
or
split "tkey,element1#element2,@element3" by ",#@"
Craig
Re: viewing invisible characters in variable watcher
Posted: Wed Sep 24, 2014 3:31 am
by mattmaier
Sorry, yes, I am indeed using 7.0.
So far, the number of characters used to "split" doesn't seem to matter, just the type of character. Three characters works just fine:
Code: Select all
on mouseUp
put "1,2 , 3,4 , 5,6 , 7,8" into testString
split testString by " , "
-- split testString by ","
-- put ", " into tDelimiter
-- split testString by tDelimiter
put empty into field "endField"
repeat for each key tKey in testString
put tKey & " " & testString[tKey] & return after field "endField"
end repeat
end mouseUp
that produces this
Code: Select all
put "1,,,,,,,,,,2,,,,,,,,,,3,,,,,,,,,,4,,,,,,,,,,5" into testString
split testString by ",,,,,,,,,,"
that produces this
Re: viewing invisible characters in variable watcher
Posted: Wed Sep 24, 2014 4:12 am
by dunbarx
Hi,
This is all ground breaking stuff. I wonder if the v.7 release notes say anything about changes to the "split" delimiters.
Craig
Re: viewing invisible characters in variable watcher
Posted: Wed Sep 24, 2014 4:08 pm
by jacque
dunbarx wrote:Hi,
This is all ground breaking stuff. I wonder if the v.7 release notes say anything about changes to the "split" delimiters.
Craig
Well, it will. My bug report was just reclassified as a documentation bug. As of 7.0, split delimiters have no character limit. RR can't reproduce my 3 character error, I'll see if I can get them a recipe.
Re: viewing invisible characters in variable watcher
Posted: Wed Sep 24, 2014 5:00 pm
by dunbarx
Well.
Then does that imply that the "split" command will form a multi-layer array, based on the number of chars that are included as delimiters? Sort of what I mentioned?
split "tkey,element1,element2,element3" by comma and comma and comma
or
split "tkey,element1,element2,element3" by ",,,"
or
split "tkey,element1#element2,@element3" by ",#@"
Craig
Re: viewing invisible characters in variable watcher
Posted: Wed Sep 24, 2014 6:35 pm
by jacque
I don't think so. It just means you can use comma-space as a delimiter, or even "headache". The array produced is still only one dimension.