bryonenger wrote: ↑Mon Apr 08, 2024 3:24 am
Code: Select all
put image sheep into animalarray[1]
answer the short name of image sheep
put animalarray[1] into temp
answer the short name of temp
I'd expect the the first two lines of code to be equivalent to the second two lines of code - but they aren't. The first two lines do what I'd expect ( they display the short name of my "sheep" image). The second two lines produce a runtime error as the fourth line executes. ( Chunk error in object expression )
The way I think of it is: Manipulating the
binary data of the image, vs manipulating a
reference to the image. A reference can be a control property such as
name/short name/long name/ID/long ID if the image resides in a stack. Or it can be a
file path, if the image is an external file.
Most frequently you will
reference, unless you want to actually manipulate the picture data.
As for understanding your code: It's very useful to get to know how to use breakpoints (click on the line number to create a red dot - code execution will halt there and you can examine your variable values, and then step through the remainder of the code.
In your code above, you can put a breakpoint on the second line and examine the variables. If you then look at animalArray[1], you would see the binary data, something like this:
âPNG
IHDR[±jgΩgAMA±è¸a IDATxúÏùyòEŸ∑Ô™Ó≥Ãöu!êÑщBÿƒ∞≈∞(*B@DQyŸÇ "aS@
A\≈·eQ"ã√öêê»ûLfÊÃY∫´Í˚£™˚Ùô93ôÑ €;øÎökÍtW◊fiO=ıl
...
This is not a reference to a control, so it doesn't have a
short name - it's the binary picture data.
Instead, what you want is a
reference to that image. If the image is stored in a stack, I would store the reference as the
long id of the image in the stack, i.e.
Code: Select all
put the long id of image "sheep" into animalArray[1] // note the quotes!!
answer the short name of animalArray[1]
You don't need to import the image to use this. Instead of storing the long id, just store the file path to the image. But then of course you can't refer to it by short name etc, since these don't live in a card (you would instead extract the file's name for example).
Hope that helps,
Stam