Do fields get assigned different numbers when compiled?

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

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Do fields get assigned different numbers when compiled?

Post by Paul D » Mon Aug 24, 2009 4:29 pm

Im trying to use the clickfield function but I am running into trouble. When I am in developer mode one of my fields return "field 73" for clickfield. So in my code I use "field 73" to determine if that field is being clicked. But when I compile to an exe that same field gets its number changed to "field 271". So the code is looking for 73 and not finding it as it is now returning 271. Why would the field get assigned a different number?

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Tue Aug 25, 2009 4:15 am

It's best to work with the field name or its id to take decisions. The field layer may vary when other controls are added to or removed from the card.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

whelkybaby
Posts: 47
Joined: Sat Nov 17, 2007 6:04 pm
Location: Worcester, UK

Post by whelkybaby » Tue Aug 25, 2009 3:03 pm

Don't any libraries that are added when you build your standalone persist as invisible groups on your card? If they are inserted in this fashion, this might account as to why the numbering of your fields changes so dramatically.

Best to stick with Jan's advice here.

Steve

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

Post by FourthWorld » Tue Aug 25, 2009 3:32 pm

When it returns "field 73" were you asking for the name or the short name?

Remember that the Rev IDE automatically assigns names to fields with "field N" where N is the number of the field at the time it was created. This can confuse some scripts (and scripters <g>), esp. if the order of objects is changed.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Tue Aug 25, 2009 4:26 pm

FourthWorld wrote:When it returns "field 73" were you asking for the name or the short name?
i was asking for the clickfield. in developer mode it was 73, in the exe it was 271. everytime.

the field number only changed for me after the compile. no biggie, i just changed the code to use the short name of the target instead. i was just curious as to why field numbers got changed after compiling. it makes clickfield a less than popular choice.

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

Post by FourthWorld » Tue Aug 25, 2009 5:37 pm

Do you have a DataGrid on that card?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Wed Aug 26, 2009 5:27 pm

yeah 4 of them.

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

Post by FourthWorld » Wed Aug 26, 2009 9:10 pm

DataGrids are comprised of any number of objects, so if the ordinal number of any DG is greater than the field clicked on, using the clickField will return the correct number but may or may not be what you expect.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Post Reply

Return to “Talking LiveCode”