itemDelimeter

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, asayd

Post Reply
chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

itemDelimeter

Post by chris25 » Fri Nov 01, 2013 12:23 pm

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.....

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Location: Plymouth, UK
Contact:

Re: itemDelimeter

Post by dave.kilroy » Fri Nov 01, 2013 1:35 pm

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
"...this is not the code you are looking for..."

macnomad2
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 63
Joined: Sat Oct 28, 2006 10:04 pm

Re: itemDelimeter

Post by macnomad2 » Fri Nov 01, 2013 1:35 pm

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...

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: itemDelimeter

Post by chris25 » Fri Nov 01, 2013 11:20 pm

Thankyou both for your replies.

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: itemDelimeter

Post by Klaus » Tue Nov 05, 2013 1:20 pm

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

macnomad2
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 63
Joined: Sat Oct 28, 2006 10:04 pm

Re: itemDelimeter

Post by macnomad2 » Tue Nov 05, 2013 1:33 pm

You are right, but it comes straight from a Runrev example ;)

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: itemDelimeter

Post by Klaus » Tue Nov 05, 2013 5:50 pm

macnomad2 wrote:You are right, but it comes straight from a Runrev example ;)
So what? 8)

macnomad2
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 63
Joined: Sat Oct 28, 2006 10:04 pm

Re: itemDelimeter

Post by macnomad2 » Tue Nov 05, 2013 5:57 pm

Ah yes, "Do what I say, don't do what I do" in my code says Runrev ;)
You are right Klaus.

Post Reply

Return to “LiveCode University”