Page 1 of 1

itemDelimeter

Posted: Fri Nov 01, 2013 12:23 pm
by chris25
I was looking and going through the 3-5-7 game code in the tutorials. This itemDelimiter was so easy to understand until I encountered it here. Since I am not writing any text anywhere I am at a loss to understand it inclusion, even setting 'space' makes no sense to me because the explanation given here is incomplete: ie what is this space? what is this space? why an item delimiter in a visual non text environment? These elaborations are so important for beginners.

set the itemDelimiter to space

The itemDelimiter is a property that can be set to specify a character that is used to separate expressions in a chunk of data. For example if you have a line of text, then you may want to use a space character to separate one word from an other.

Sorry! Had to have a moan, everyone is out...and my cat is sleeping.....

Re: itemDelimeter

Posted: Fri Nov 01, 2013 1:35 pm
by dave.kilroy
Hi Chris
chris25 wrote:what is this space?
I'm tempted to answer "Space, the final frontier" :)

But to be serious - I don't know the 3-5-7 game code you're referring to but "set the itemDelimiter to space" could be perfectly valid if there had been an earlier "set the itemDelimiter to comma"

...go and stroke your cat...

Kind regards

Dave

Re: itemDelimeter

Posted: Fri Nov 01, 2013 1:35 pm
by macnomad2
Hello, lost in space ?

I assume you refer to these lines
set the itemDelimiter to space
if item 1 of the name of target is "button" then...

In Livecode you manipulate strings of characters all the time, even if the result on the screen does not show any text.
So when you have a string of text there are simple ways to get chunks of it.
Usually you can take words in a string of text (as in a normal sentence, words are separated by "spaces")
By default Livecode as an "itemdelimiter" which is a comma, so item 2 of "one,three,five,two" is ... "three"
If you set the item delimiter to space, Livecode looks for spaces, so item 2 of the preceding string would be ... empty

But item 2 of "Twenty one,twenty three" would be ... ?
By default with a comma, it would be ... "twenty three"
With the itemdelimiter set to space, it is ... ""one,twenty"
Weird, no ? ;)

So the answer is on the following lines in the script, because "the name of the target" can be different things depending on the target.
If you clicked on a button the name of the target starts with something like :
button "test" of card ...
So the first item is "button"

Ok, I go back to sleep...

Re: itemDelimeter

Posted: Fri Nov 01, 2013 11:20 pm
by chris25
Thankyou both for your replies.

Re: itemDelimeter

Posted: Tue Nov 05, 2013 1:20 pm
by Klaus
Hi Chris,

setting the itemdel to SPACE does not make sense, except in some very rare cases.

Better use "WORD X of XYZ", because:
1. WORDS in Livecode are separated by SPACE, comma or a full stop by "nature"
2. No need to set the itemdel
3. all in all less typing (MOST important to me :D )


Best

Klaus

Re: itemDelimeter

Posted: Tue Nov 05, 2013 1:33 pm
by macnomad2
You are right, but it comes straight from a Runrev example ;)

Re: itemDelimeter

Posted: Tue Nov 05, 2013 5:50 pm
by Klaus
macnomad2 wrote:You are right, but it comes straight from a Runrev example ;)
So what? 8)

Re: itemDelimeter

Posted: Tue Nov 05, 2013 5:57 pm
by macnomad2
Ah yes, "Do what I say, don't do what I do" in my code says Runrev ;)
You are right Klaus.