Page 1 of 1

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

Posted: Sat May 07, 2016 6:23 pm
by mrcoollion
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

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

Posted: Sat May 07, 2016 7:08 pm
by dunbarx
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

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

Posted: Sat May 07, 2016 8:02 pm
by mrcoollion
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

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

Posted: Sat May 07, 2016 8:08 pm
by dunbarx
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

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

Posted: Sat May 07, 2016 8:14 pm
by mrcoollion
I will make a test stack tomorrow and test in both versions.

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

Regards,

Paul

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

Posted: Sun May 08, 2016 11:33 am
by mrcoollion
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

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

Posted: Sun May 08, 2016 2:27 pm
by mrcoollion
Found the problem.. made a typo. There was a space where there should not be one :mrgreen:

Post closed and thanks again Craig.

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

Posted: Tue May 10, 2016 2:01 am
by dunbarx
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

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

Posted: Tue May 10, 2016 2:47 pm
by mrcoollion
Well with livecode coding is not that big of an issue once you know what to make :D