using numbers as selectors

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
sn4fu
Posts: 4
Joined: Mon Mar 23, 2015 11:46 pm

using numbers as selectors

Post by sn4fu » Tue Nov 10, 2015 5:25 pm

I have a grid of 216 graphic rectangles.

i have numbered these according to position, essentially from top to bottom.

If I select say graphic 13 the graphic returned is 38.

Now it seems live code is ignoring my number names and renumbering from left to right.

ie. graphic 38 is the thirteenth graphic if I count left to right.

I realise that i should probably not use numbers for names but i need to move around the squares according to the results of a equation.

it does not seem to make a difference, if I use graphic "13" or graphic 13.

I use 13 just an example but this happens for all graphics.

I suppose 1 solution would be to prefix an alpha character to the name and then strip out later, but if i could get my head around whats happening or how live code does this, i might have a more elegant solution.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: using numbers as selectors

Post by dunbarx » Tue Nov 10, 2015 5:35 pm

JUST DON'T USE...

Sorry.

Just don't use numbers for any naming purpose, ever, ever, ever...

Sorry. Ahem.

LiveCode has a native property for controls, called the "number". This is an integer. If you have another integer in another property, like the "name", you are going to regret it when you try to reference those controls.

So do use an alpha scheme, like "C1R3" (column 1, Row3), or "a13" (same thing, unless you get into double digits, where it becomes difficult to decipher) or whatever. You will not regret it. Such a method is robust; it will survive changes you make to other properties. It is simple and straightforward to extract the row/column values from whatever schema you settle on, using a function that you can call at any time. And even if your integer naming works now, it may not when you add functionality or fool around with other aspects of your stack.

Craig Newman

EDIT. Perhaps I was not clear. If you have controls that have numbers for names, and you "set the loc of control 3...", it is the layer number that LC will reference, not the name.

Post Reply