One extremely quick question and one extremely long one

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, asayd

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

One extremely quick question and one extremely long one

Post by chris25 » Sun Oct 13, 2013 3:40 pm

Thought for the purpose of clarity better to start a new thread.

Question 1:

A little bit of ambiguity here….

In the size and Position box this is described in the LCU lecture material:

• Layer: This number identifies the object in relation to other objects (buttons, fields, images, etc.) on the card, in the order in which they were created. This can be changed by either typing a new number or by using the arrow buttons to the right.
• Number: This number identifies the object in relation to other objects of its type in the order in which they were created. This can be changed by changing its layer or by using the arrow buttons to the right.

I scrutinized these sentences, as far as I can make out they are saying Exactly the same thing apart from a subtle deviation in the clause: "of its type", if this is the difference I am meant to understand then the ambiguity is what is baffling me. If a button and a field and an image are "Different types", what on earth are "Same types"?

Simon if you are around I really could do with a spot of help understanding How to Read the dictionary, namely just the syntax explanations, I was looking up how to Use the Date Message, and reading this:

[long | abbr[rev[iated]] | short] [english | system | internet] date
the [internet] [english | system] date
date()

Theses are just words to me separated by 'things' I mean what does ""abbr[rev[iated]] "" mean? Apart from abbreviated, but what is with all the dissections ? I am doing a specific exercise at the moment, the LCU lectures really have not prepared you enough in order to do this exercise, and I can not find the tutorial that shows you how to actually write properly, the liveCode script editor keeps telling me I am getting it right even though I keep changing the syntax slightly, that's amusing or I am just VERY lucky. So another leap here is needed, about 15 minutes and I will have it under my belt, otherwise I will be hours and hours.

Thanking you.

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: One extremely quick question and one extremely long one

Post by SparkOut » Sun Oct 13, 2013 4:11 pm

Quick answer:
Object 1 has the lowest layer. Object 2 has the next lowest layer.
And so on.
So if you were to loop through the controls on a card

Code: Select all

repeat with i = 1 to the number of controls of this card
it would start with the lowest layered and work towards the top. Simple enough. Now, the control on layer 1 may be a field, layer 2 may be a button, layer 3 another field, and layer 4 an image, layer 5 another image and layer 6 may be another field. So each type of object will have its own ordinal, starting lowest first again. Thus field 1 will be the one on layer 1, field 2 will be on layer 3 and field 3 will be on layer 6. Similarly button 1 will be layer 2 and image 1 will be layer 4 and image 2 on layer 5.
Because layers are so transient, it is always far better to refer to objects by their name or id, rather than their "number".
The longer answer will have to wait until I can use a proper computer, not this phone. Btw, I qualify to answer as my name is Simon too!

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

Re: One extremely quick question and one extremely long one

Post by chris25 » Sun Oct 13, 2013 4:50 pm

Hi the other simon, Ok, I understand layers, vritually the same concept as illustrator and photoshop, and layers in CSS, so I grasp that fine. But what I still do not get, despite having read your post three times, is what on earth the number underneath the layers number is telling me. Layer 2 and then underneath I see number = 3 for example. Especially when I see layer 1 = number 1 and layer 2 also = number 1?

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: One extremely quick question and one extremely long one

Post by SparkOut » Sun Oct 13, 2013 4:59 pm

The longer answer isn't, on re-read, too long either.

The part in square brackets [indicates optional syntax][to be included or not]

Within the square brackets the pipes (or vertical dividers) indicate options for the optional group.
So:
[long | abbr[rev[iated]] | short] [english | system | internet] date
the [internet] [english | system] date


abbr[rev[iated]] means you can use the full word "abbreviated" or the abbreviation "abbrev" or the even more abbreviated abbreviation "abbr"


It means you could ask for
the long system date, or
the abbreviated internet date, or
the short date, or
the system date, or
the abbr english date

Livecode offers an "English like" syntax as noted above, but most "English like" functions can also be interrogated in a more "programmer familiar" function format as an alternative:

date()

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: One extremely quick question and one extremely long one

Post by SparkOut » Sun Oct 13, 2013 5:07 pm

Sorting out the cross-post:
chris25 wrote:Hi the other simon, Ok, I understand layers, vritually the same concept as illustrator and photoshop, and layers in CSS, so I grasp that fine. But what I still do not get, despite having read your post three times, is what on earth the number underneath the layers number is telling me. Layer 2 and then underneath I see number = 3 for example. Especially when I see layer 1 = number 1 and layer 2 also = number 1?
The "number" is the number of that "type", in the case of layer 1 = number 1 and layer 2 = number 1 the objects on layer 1 and 2 will be different types (eg a field and a button).
In my earlier post example if you inspected the first field, you would see layer = 1 and number = 1, it's the first field and on the first layer. The next object on layer 2 is a button, so the inspector would show layer = 2, number = 1, it's the first button, but on the second layer. The next object would be layer = 3, number = 2, it's the second field, happening to sit on layer 3. If you were to move this field to be the bottom layer, then its number would also change as well as the layer, because it would become the first field.
Hence numbers... don't get too involved with them except in the case that you want to loop through all fields on a card, for instance, and not care about the order as long as you handle them all. Give fields and other objects meaningful names and use those to refer to them.

The other thing about layers, is that it determines "tab order" or the order in which controls are focussed. When exiting a field with Tab on Return (autoTab set to true) then it will move focus to the control in the next layer up. Except for making sure that objects don't obscure each other if they overlap, that's about all I use layers for.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: One extremely quick question and one extremely long one

Post by Simon » Sun Oct 13, 2013 5:47 pm

Hi Chris,
I hope you understood what sparkout said, he's got it right.

About the Layer/Number:
Remember that I was using fld 1 and not fld "one"? If there where 10 controls/layers on a stack but only 2 of them were fields at say layer 3 and layer 8 I could still address them as fld 1 and fld 2.

Code: Select all

put "I am learning liveCode" into fld 2
Regardless of field 2's layer, that code would put the sentence (string) into the second highest layered field.
Rats... even I don't like that explanation :?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

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

Re: One extremely quick question and one extremely long one

Post by chris25 » Sun Oct 13, 2013 7:03 pm

Ok "the other simon" I get the numbers (a bit) glad I can ignore them, they seem to just confuse th eissue really. the layers I know are important and I give names to everything so I should never have problems there.

But
[long | abbr[rev[iated]] | short] [english | system | internet] date
the [internet] [english | system] date
is still awkward to understand.

Please could you give me a couple of examples, I looked at the examples in the dictionary but there is no connection for me to be able to see how I can understand the syntax description by looking at the example.
For example could I write:
put english date "fld"
OR
put internet date "fld"
OR
put abbrev system date "fld"
OR
put the interent english date "fld"

If these are all correct then I understand it. Hopefully.

Simon, any chance of a skype session for 15 minutes at your convenience. As said above earlier, I need to see something in action. The LCU bit i am on has not really given me enough to go on, and the help files are churning up ridiculously irrelevant topics. See once - cemented forever!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: One extremely quick question and one extremely long one

Post by Simon » Sun Oct 13, 2013 7:20 pm

Hi Chris,
Sure, just skype me a message.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: One extremely quick question and one extremely long one

Post by jacque » Sun Oct 13, 2013 7:42 pm

chris25 wrote:Ok "the other simon" I get the numbers (a bit) glad I can ignore them, they seem to just confuse th eissue really. the layers I know are important and I give names to everything so I should never have problems there.
The one way they're important is that you should never name a control with a number. It will fail in unexpected ways, because the engine will interpret the number as a layer rather than a name.

Later you will need to use layers in scripts, particularly when you want to cycle through them all to do something to them. Say you want to change the background color of all the buttons on a card, but only the button. You need to use their relative (button) layer numbers to refer to them in the loop:

Code: Select all

repeat with x = 1 to the number of buttons -- you have here said here that you only want to consider button types
  set the backgroundColor of btn x to "blue" -- x will be a number, relative to only the other buttons
end repeat
The repeat loop will work because regardless of the absolute layer of each button, you've specified a button type and so the relative layer number will be used. Only buttons will change color, even if there are intervening fields in the absolute layering order.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: One extremely quick question and one extremely long one

Post by chris25 » Tue Oct 15, 2013 6:09 pm

Hallo Jacque, forgot to say thankyou as I was re-reading your text. Please forgive the oversight I was not ignoring you.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: One extremely quick question and one extremely long one

Post by jacque » Tue Oct 15, 2013 6:46 pm

No thanks needed, but thanks. :) Pay it forward later when you're a pro.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “LiveCode University”