Set The Menu Items of an Option Menu (script)

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Set The Menu Items of an Option Menu (script)

Post by Nakia » Sun Mar 04, 2012 9:37 am

I must be doing something wrong

So I did as you said and set a custom property..

On field I have
Set the lastLineClicked of me to word 2 of the clickLine

Card
On clearPilot
Delete line lastLineClicked of field "Pilots"
end clearPilot

All triggered by button

Using mouse up to clearPilot

Getting an error on the Delete line in the card script..

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Set The Menu Items of an Option Menu (script)

Post by Nakia » Sun Mar 04, 2012 10:12 am

I think I just remembered something from the beginners course..

Customer properties are not compatible with chunk expressions..should work if I place it into variable first then apply chunk expression..

Is this correct?

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Set The Menu Items of an Option Menu (script)

Post by Nakia » Sun Mar 04, 2012 10:29 am

Nope that wasn't it..

I'm confused..I can see the custom property updating on the field when impress it...

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Set The Menu Items of an Option Menu (script)

Post by Nakia » Sun Mar 04, 2012 11:04 am

Yay got it..
Only Gould get to work if I wrote it to variable in the card script and then deleted based upon that variable..

Thanks for alls help

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Set The Menu Items of an Option Menu (script)

Post by dunbarx » Sun Mar 04, 2012 5:54 pm

This will work. You may have done "something wrong" in that you missed the syntax just a bit. You wrote:

On clearPilot
Delete line lastLineClicked of field "Pilots" --NOT CORRECT
delete line the lastLineClicked of field "pilots" of field "pilots" --CORRECT
end clearPilot

Seem odd? It isn't. Think about how this is resolved. The "delete" command needs a value and a target, as in: delete line 2 of field "pilots"

The "2" comes from "the lastLineClicked of field "pilots". See? This string contains the information required to get that "2".

But then where to delete from? You need to tell it "of field pilots". Do not be confused by the repetition of the clause. You will get used to it, and it makes sense.

Write back if this is not clear. You will find this sort of construction all the time; it is not silly or redundant, it is a result of LiveCode being able to process based on properties, which is a very powerful too. But it does seem to be peculiar in the way it reads sometimes.

Craig Newman

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Set The Menu Items of an Option Menu (script)

Post by Nakia » Mon Mar 05, 2012 1:43 am

Yeah that is spot on..

It didn't seem correct me repeating so I put into a variable so it made more sense to me..
I ended up with.....
Put lastLineClicked into tDeleteLine
Delete line tDeleteLine of field "Pilots"

But in hind sight
Could have used....
Delete line lastLineClicked of field "Pilots" of field "Pilots"

Confusing but I do get it now..thanks so much mate...

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

Re: Set The Menu Items of an Option Menu (script)

Post by Klaus » Mon Mar 05, 2012 1:08 pm

Hi Kia,

if you set some parens or slice it into little bits, this is not too irritating! :D
And please use the THE keyword when accessing custom properties!
...
put the lastLineClicked of field "Pilots" into tLine2Delete
## Will give you a NUMBER that you now can use in your next statement:

delete line tLine2Delete of fld "Pilots"
...

Now if you set parens, you will see that this is the way this will be interpreted by the engine:
...
delete line (THE lastLineClicked of field "Pilots") of field "Pilots"
...
The expression in parens will be solved first and then the rest of the line!
As you see, not really irritating, but extremely logical and reproducable 8)


Best

Klaus

Post Reply

Return to “Talking LiveCode”