Rename an Icon?

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

pugalug
Posts: 15
Joined: Mon Jan 29, 2024 9:19 pm

Rename an Icon?

Post by pugalug » Mon Mar 25, 2024 4:41 am

Hello,
I have imported as control some image files and saved them to a separate card in my stack. I want to use these images as button icons. I am making a spinner game and the id of the images keeps changing. For example, my image is called horse and it's ID is 210041 in the icon menu. I go into my code and change it to reflect the ID 210041 and go back and find it is now changed to 210053 (or something similar) I have looked at the remote control tutorial and it mentions going to the "player card" and also the "property inspector" and select "icons." The latest liveCode version doesn't have these and I don't know how to rename the images so that they don't keep changing numbers. I would like to name them "horse" etc. without a number if possible but if I do need to use a number, how do I get an icon number that won't change? Thank you!

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Rename an Icon?

Post by stam » Mon Mar 25, 2024 9:43 am

The latest livecode has all the stuff you say it doesn’t… but I suppose that’s an indictment of the IDE more than anything else.

The “numbers” you mention are (or should be) the “id” which all controls and visible constructs have. The name is independent of this and. You can carnage the names without consequence.
Be aware the id will change if you copy/past the image however - it’s allocated by the IDE.

The are are multiple nuances to “name”.
The name as such includes the class (ie image <myImage>)
The short name is the purr name (ie <myImage>)
The long name fully qualifies full ownership of the control (ie image <myImage> of card <myCard> of stack <myStack>)

OR you can refer to it by id, which is unique to the stack (ie image id 10024)
Likewise the long id fully qualifies ownership (ie image id 12345 of card 43435 of stack )

The inspector appears any time you double click on a control. In contrast to older tutorials, the various sections in the PI are now tiny icons at the top of the inspector. If you open the PI for a button you will see a section for icons…

Hope this answers your questions?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Rename an Icon?

Post by richmond62 » Mon Mar 25, 2024 10:02 am

You can, obviously, name all the images you use as icons.

If you want to give your images numbers, then to avoid the problem with the IDE mucking around with image ID numbers surely the best thing to do is name the images with numbers?

This will mean that the image you name "27" will still be called "27" if the IDE for some reason changes image "27"'s ID from 2013 to 2078.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Rename an Icon?

Post by bn » Mon Mar 25, 2024 10:43 am

richmond62 wrote:
Mon Mar 25, 2024 10:02 am
You can, obviously, name all the images you use as icons.

If you want to give your images numbers, then to avoid the problem with the IDE mucking around with image ID numbers surely the best thing to do is name the images with numbers?

This will mean that the image you name "27" will still be called "27" if the IDE for some reason changes image "27"'s ID from 2013 to 2078.
Please do not use numbers to name an object.

From the user guide
Avoid using numbers as object names
search for that string in the user guide for an explanation.

Also you should avoid using numbers as first character of an object name. It is ok to use numbers in object names like "myButton2"


Kind regards
Bernd

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Rename an Icon?

Post by stam » Mon Mar 25, 2024 10:44 am

GUYS - the OP never stated (s)he was using numbers as names. Quite the opposite...

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Rename an Icon?

Post by richmond62 » Mon Mar 25, 2024 10:59 am

True.

Personally I always do THIS sort of thing when I want numbered image sequences:

'X1', 'X2', 'X3' . . .

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Rename an Icon?

Post by bn » Mon Mar 25, 2024 11:13 am

Hi Pugalug,
I have imported as control some image files and saved them to a separate card in my stack. I want to use these images as button icons. I am making a spinner game and the id of the images keeps changing
You could name your images like "horse1", "horse2" etc. and then

Code: Select all

set the icon of button "myHorseButton" to the short id of image  "horse1" of card "myImages"

Code: Select all

set the icon of button "myHorseButton" to the short id of image  "horse2" of card "myImages"
Kind regards
Bernd

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Rename an Icon?

Post by richmond62 » Mon Mar 25, 2024 11:26 am

Yeeeeees: I got hold of the wrong end of the stick: Sorry. 8)
-
Fruity.jpg
-
https://www.dropbox.com/s/kzcrkbqsyfzej ... e.zip?dl=0

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Rename an Icon?

Post by stam » Mon Mar 25, 2024 12:21 pm

The OP's issue was that the ID he was using appears to be changing. The naming is a different issue.
I'm not aware this can happen unless the image has been duplicated/pasted - but perhaps I'm wrong.

S.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Rename an Icon?

Post by richmond62 » Mon Mar 25, 2024 12:38 pm

Once an image has been imported into a stack its ID should never change.

The only way I can see someone thinking this is happening is if they are copy-pasting and/or duplicating the image onto different cards.

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

Re: Rename an Icon?

Post by dunbarx » Mon Mar 25, 2024 2:47 pm

I imported an image onto a card and recorded the ID that LC assigned to it: 1003

I then cut the image and immediately pasted it. The ID of that image was 1006.

This all makes sense to me. The IDE creates ID's as controls are created, without any thought to maintaining their original assignments. It obviously keeps track of previous assignments, and cares nothing about the fact that it is the very same control put back in the very same location. But is that sort of thing the issue is here?

Craig

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

Re: Rename an Icon?

Post by dunbarx » Mon Mar 25, 2024 2:55 pm

Comforting is the fact that all other properties, like the control name, are held constant. The ID is therefore a different kind of property than any other, pertinent to the ongoing development of the controls comprising a stack, as opposed to any information about the controls themselves.

I suppose one could conceivably keep track of all the ID's ever created in a stack, and find a use for that number in some way. My test stack had just one control, but two historical ID's.

Craig

pugalug
Posts: 15
Joined: Mon Jan 29, 2024 9:19 pm

Re: Rename an Icon?

Post by pugalug » Mon Mar 25, 2024 7:02 pm

stam wrote:
Mon Mar 25, 2024 9:43 am

The inspector appears any time you double click on a control. In contrast to older tutorials, the various sections in the PI are now tiny icons at the top of the inspector. If you open the PI for a button you will see a section for icons…

Hope this answers your questions?
Thank you for your reply. I double clicked on the button with my icon on it and sure enough, it opened the project browser for that icon and now it shows a different id for it. Last night this icon id was 210041 and today it is 210052. I don't understand why and how I can keep it the same so I can code properly.

(I'm still studying everything else you and the others mentioned but this stuck out as applying perfectly to my problem) Thank you so much!

pugalug
Posts: 15
Joined: Mon Jan 29, 2024 9:19 pm

Re: Rename an Icon?

Post by pugalug » Mon Mar 25, 2024 7:13 pm

richmond62 wrote:
Mon Mar 25, 2024 10:02 am
You can, obviously, name all the images you use as icons.

If you want to give your images numbers, then to avoid the problem with the IDE mucking around with image ID numbers surely the best thing to do is name the images with numbers?

This will mean that the image you name "27" will still be called "27" if the IDE for some reason changes image "27"'s ID from 2013 to 2078.
Thank you for the reply! No, I don't want to give them numbers for names. I am just trying to figure out how to keep their id the same so I can code my statements properly. I am not understanding why the icon id is changing. Maybe I don't need to worry about the id name? I am still learning - and enjoying doing so.

pugalug
Posts: 15
Joined: Mon Jan 29, 2024 9:19 pm

Re: Rename an Icon?

Post by pugalug » Mon Mar 25, 2024 7:18 pm

stam wrote:
Mon Mar 25, 2024 12:21 pm
The OP's issue was that the ID he was using appears to be changing. The naming is a different issue.
I'm not aware this can happen unless the image has been duplicated/pasted - but perhaps I'm wrong.

S.
Yes. This is what is happening. I haven't duplicated or pasted the icon BUT I did duplicate the three buttons. Could that have something to do with the icon names changing?

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”