Cannot get the ID of an image I just created on another card

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Cannot get the ID of an image I just created on another card

Post by mrcoollion » Sat May 07, 2016 6:23 pm

Cannot get the ID of an image I just created on another card with statement:

Code: Select all

put the ID of image timagename of card "Imageholder" of this stack into TheImageID
I get error: execution error at line 111 (Chunk: no such object), char 8

What am I trying to do:
Step 1: Copy a button from card "buttonstemplate" to card "Menu" and rename it to "Button1" >>>> this works fine.
Step 2: Copy an existing image on the current card to card "Imageholder" and rename it to e.g. "Button1_Imagename" >>>> this works fine.
Step 3: Now I want to set the icon of "Button1" on card "Menu" to the id number of the image "Button1_Imagename" on card "Imageholder" so it shows the image on the button. This gives the mentioned problem.
To simplify things I have tried to put the ID of the image in a variable 'TheImageID' but still the same error, (Chunk: no such object), char 8.

I checked the image name in variable 'timagename' and the card name over and over again. Images are available at card "Imageholder"
Am I doing something that is not possible or allowed ?

The original statement was:

Code: Select all

set the icon of button ButtonName of card"Menu" to the id of image timagename of card "Imageholder" 
Working in Livecode 8.0 (and love it ;-)

Regards,

Paul

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

Re: Cannot get the ID of an image I just created on another

Post by dunbarx » Sat May 07, 2016 7:08 pm

Hi.

The line of code seems good. If it is a variable, in the debugger, is there a valid image name in tImageName? LC will try to treat this as a variable first, and only if it fails, will it begrudgingly treat it as a literal. Is it a literal?

Always, always do quote literals and object references, by the way.

Craig Newman

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Cannot get the ID of an image I just created on another

Post by mrcoollion » Sat May 07, 2016 8:02 pm

Hi Craig,

Thank for the fast reply. There is a valid image name in variable timagename that also exists on the card mentioned. See the attached debug screen print.
The screen print shows on the left the code and the variable with the data in it and on the right the project browser with the card "Imageholder" and images.

Regards,

Paul
Attachments
printscreen_timagename.zip
printscreen
(111.91 KiB) Downloaded 196 times

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

Re: Cannot get the ID of an image I just created on another

Post by dunbarx » Sat May 07, 2016 8:08 pm

Hmmm.

I am still in v.6. If you duplicate your handler and controls in a v.6 stack does it work there? Easy to see if it does, which means it is a v,8 issue, and you can send the stack to QCC.

Craig

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Cannot get the ID of an image I just created on another

Post by mrcoollion » Sat May 07, 2016 8:14 pm

I will make a test stack tomorrow and test in both versions.

I'll let you know the results through this post.

Regards,

Paul

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Cannot get the ID of an image I just created on another

Post by mrcoollion » Sun May 08, 2016 11:33 am

Hi Craig

Well I build a simple stack that does the same and it works perfect :shock:

So I guess I am doing something wrong :? >> (problem has been found , see last post...)

I attach the stack here for people who like to have an example with copying buttons and images and setting icons of buttons.


Regards,

Paul
Attachments
Set_IconIDButton.zip
Copy Button and Image and set icon of button
(8.74 KiB) Downloaded 200 times
Last edited by mrcoollion on Sun May 08, 2016 7:58 pm, edited 1 time in total.

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Cannot get the ID of an image I just created on another

Post by mrcoollion » Sun May 08, 2016 2:27 pm

Found the problem.. made a typo. There was a space where there should not be one :mrgreen:

Post closed and thanks again Craig.

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

Re: Cannot get the ID of an image I just created on another

Post by dunbarx » Tue May 10, 2016 2:01 am

I am glad you rewrote the code, and did not just copy and paste it. Only in that way could you test for exactly what you found, a typo.

Craig

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Cannot get the ID of an image I just created on another

Post by mrcoollion » Tue May 10, 2016 2:47 pm

Well with livecode coding is not that big of an issue once you know what to make :D

Post Reply