"split as set" documentation mystifying

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

"split as set" documentation mystifying

Post by aetaylorBUSBnWt » Fri Jan 22, 2021 3:15 pm

split variable {by | using | with} primaryDelimiter as set

The following is from the LiveCode 9.6.2 dictionary

If you use the as set form the split command converts the passed variable to an array with the keys being equal to the original list and the values being true.

For example, the following statements create an array:

Code: Select all

put "A apple;;B bottle;;C cradle" into myVariable 
split myVariable by ";;" and space 

# resultant array looks like this:
KEY    VALUE 
A    apple 
B    bottle 
C    cradle 
First, the example is not about using the "as set" version of the split command.
Second, how does LiveCode know what the original keys are?
The input can be a string, so the "keys" could be any number of characters "terminated" by some particular character.

Given the above, this means that "as set" is assuming some particular format for how the input is constructed.
Yet that format is NOT stated, it is assumed that the reader knows what it is.

What is this particular input format that is needed for the "as set" version of split.

Finally, what does "values being true" mean?

Oh, a final issue (possibly because the documentation was modified but not proofread entirely) - later in the Dictionary documentation for split it refers to the "second form" of split and then proceeds to describe the split by row and column. "Split as set" is the second type in the list of types of split shown at the top of the Dictionary entry for split.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: "split as set" documentation mystifying

Post by FourthWorld » Fri Jan 22, 2021 10:06 pm

The example provided related to the paragraph above the one about "as set", the section about using two delimiters.

The "as set" option simply splits on one delimiter, with the resulting array being a set of keys which are the values of the original list, where is element value is set to "true".

Thanks for bringing this documentation anomaly to our attention. I've filed a bug report for it:
https://quality.livecode.com/show_bug.cgi?id=23071
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: "split as set" documentation mystifying

Post by aetaylorBUSBnWt » Fri Jan 22, 2021 11:42 pm

First, thanks for posting the bug.

From what you said, I believe the following:

The incoming variable may contain ONLY keys separated by the "primaryDelimiter".


If not, then how does the split command distinguish between a key and a value?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: "split as set" documentation mystifying

Post by FourthWorld » Fri Jan 22, 2021 11:51 pm

It doesn't need a supplied value, since the purpose of "split..as set" is to return an array where the value of all keys is "true".
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: "split as set" documentation mystifying

Post by bwmilby » Sat Jan 23, 2021 12:12 am

The second form comment is correct. The first form allows specifying the delimiter(s) and the second uses the rowDelimiter and the columnDelimiter.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: "split as set" documentation mystifying

Post by FourthWorld » Sat Jan 23, 2021 12:27 am

bwmilby wrote:
Sat Jan 23, 2021 12:12 am
The second form comment is correct. The first form allows specifying the delimiter(s) and the second uses the rowDelimiter and the columnDelimiter.
Yes, the example itself is correct, but it relates to the form described two paragraphs above it, not the one immediately preceding it.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: "split as set" documentation mystifying

Post by bwmilby » Sat Jan 23, 2021 1:52 am

I think that “as set” is still part of the first form (where a delimiter is provided). I agree that the example should be moved. I’ll probably submit a PR on it this weekend unless someone else does it first.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”