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!
I have a 10x10 matrix where each cell is a graphic.
I would like to name them by their respective serial number: 1, 2, 3, ...., 100.
I'm afraid that this would create a problem, since LiveCode automatically converts the string form of a number to its numerical value.
Does
What Klaus means is that you should never name anything with a pure number. There are too many ways that the engine can become confused. So if you have a field, say, named "15", it is almost a certainty that you will try to put something into "field 15", and then what is LC supposed to make of it?
AS Klaus suggested, change your thinking to "a1". "a2", etc.
on mouseUp
put 0 into S
put 0 into T
repeat with Q = 1 to 10
repeat with N = 0 to 9
create graphic "g"&Q&N
set the rect of graphic ("g"&Q&N) to S,T,S +50,T+50
add 50 to S
end repeat
add 50 to T
put 0 into S
end repeat
end mouseUp
There is a 10x10 grid of 50px x 50px squares with sequential ID numbers and almost sequential names(will need to change 10 of them, I'm too lazy). If you wanted a different size then just change all the 50's to a new number.
Simon EDIT: Fixed the code so that the names are also in sequential order...too easy
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
on mouseUp
put 1760 into tIDNumAdj
repeat with i = 1 to 704
put "Image"&i into tNewName
put "image id "&tIDNumAdj&" of card id 1002 of stack ""e&"MapArea""e&" of stack ""e&"D:/Projects/TileMapper/TileMapper.rev""e into tNewID
set the name of tNewID to tNewName
add 1 to tIDNumAdj
end repeat
end mouseUp
Of course you will have to adjust it to your needs, repeat to 100 instead of 704, change the path to your stack, change the starting number for the IDs etc.
........
repeat with Q = 1 to 10
repeat with N = 0 to 9
create graphic "g"&Q&N
......
Doesn't that translate to g10, g11, ...., g109 ? I was trying to make the names go from g1 to g100.
I didn't realize that it would mess up the order of the ID numbers, I guess!
on mouseUp
put 0 into S
put 0 into T
put 0 into R
repeat with Q = 1 to 10
repeat with N = 0 to 9
add 1 to R
create graphic "g"&R
set the rect of graphic ("g"&R) to S,T,S +25,T+25
add 25 to S
end repeat
add 25 to T
put 0 into S
end repeat
end mouseUp
There's your 1-100
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
And, yes, Klaus, I must remember not to get sloppy.
Always parenthesize when concatenating object names!
And use space between & and its arguments (even though LiveCode is forgiving).
And comment my code liberally.
........