Image not shown

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

Post Reply
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Image not shown

Post by francof »

Hi all,
In a card I have some jpeg images imported as control. at user's choice I want to show one of these into a image area.
I have tried this

Code: Select all

put img "aglianico" into img "imgFoto"
no error is given, but no image is show.

thanks for help
best
franco
sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Image not shown

Post by sefrojones »

Are the imported images on the same card as the image area? If not you should try something like this:

Code: Select all

put img "aglianico" of cd MyImagesCard into img "imgFoto" of cd MyDisplayCard
You may also want to refer to the images by ID number instead of name...


--Sefro
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Image not shown

Post by francof »

Hi Sefro
yes, they are in the same card.
sefrojones wrote: ...

You may also want to refer to the images by ID number instead of name...


--Sefro
I will try

ciao
franco
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Image not shown

Post by Klaus »

Buonasera Franco,

"put img 1 into img 2" will only work with IMPORTED images mot with referenced images!

In that case do:

Code: Select all

set the FILENAME of img 2 to the filename of img 1
Best

Klaus
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Image not shown

Post by francof »

Hi Klaus,

I do not understand where I'm wrong, no error given, but no image displayed

Code: Select all

   put (the selectedText of fld tNomeFld & ".jpg") into tFoto
   set the filename of img "ImgAnteprima" to the filename of img tFoto
the referenced images are named like the content of the rows of a list field.
E.G. for Mary in the field there is a picture mary.jpg in the card.

anyway I have tried also to directly use the name of the image:

Code: Select all

 set the filename of img "ImgAnteprima" to the filename of img "aglianico.jpg"
same result.

best
franco
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2734
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Image not shown

Post by jmburnod »

Hi Franco,
Nothing wrong for me in your script.
The mistake is elsewhere.
What do you get in tFoto ?
What is the filename of img tFoto ?
best regards
Jean-Marc
https://alternatic.ch
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Image not shown

Post by francof »

Hi Jean-Marc,

into tFoto I put the name of the image I want to show, obtained with the content of the line I have clicked in the list field (e.g.: aglianico) + the constant ".jpg" the result is aglianico.jpg, which is the file name of the referenced image in the card.

the file name is correct, I'm sure, as said I have no error in the script.
for test I have put this:

Code: Select all

 set the layer of img (the selectedText of fld tNomeFld & ".jpg") to top
the image is correctly put in front of all the others. boh!

one more thing: if a image is not existing, how can I intercept the message to avoid the error: :"... execution error at line 43 (Chunk: no such object)..."

ciao
franco
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2734
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Image not shown

Post by jmburnod »

Hi Franco
how can I intercept the message to avoid the error: :"... execution error at line 43 (Chunk: no such object)..."
just this:

Code: Select all

if there is an img "myNameImage" then
https://alternatic.ch
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Image not shown

Post by francof »

Hi Jean-Marc,
jmburnod wrote:Hi Franco
how can I intercept the message to avoid the error: :"... execution error at line 43 (Chunk: no such object)..."
just this:

Code: Select all

if there is an img "myNameImage" then
so easy, I always forget LC is english like.... or this may be my problem.

well for now, instead to put the selected image in the Image Area object, I show and put it on the front over all others images.

Code: Select all

if there is an img  (the selectedText of fld tNomeFld & ".jpg") then
      set the layer of img (the selectedText of fld tNomeFld & ".jpg") to top
      show img (the selectedText of fld tNomeFld & ".jpg")
end if
...
   hide img (the selectedText of fld tNomeFld & ".jpg")
a question:
if I am not wrong, is not possible to change the layer of grouped objects. is it true?

ciao
franco
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Image not shown

Post by Klaus »

Buongiorno Franco,
francof wrote:...if I am not wrong, is not possible to change the layer of grouped objects. is it true?
it IS possible in fact, but is also asking for trouble, because this way one can easily put a control OUT OF the group!
Check "relayer" and "relayergroupedcontrols" in the dictionary and do it at you own risk :D

Hint for saving a LOT OF TYPING:
When concatenating object names -> the selectedText of fld tNomeFld & ".jpg"
do this ONCE and put the contatenated name into a variable!

Code: Select all

...
## Object names in QUOTES!
put the selectedText of fld "tNomeFld" & ".jpg" into tImageName
if there is an img tImageName then
      set the layer of img tImageName to top
      show img tImageName
end if
...
hide img tImageName
...
Best

Klaus
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Image not shown

Post by francof »

guten Abend Klaus,

thanks for the hint. I edit the script and I'll keep in mind.
Klaus wrote: it IS possible in fact, but is also asking for trouble, because this way one can easily put a control OUT OF the group!
Check "relayer" and "relayergroupedcontrols" in the dictionary and do it at you own risk :D
....
NO thank you! is better than no.

below a pair of images among those that are referenced in the card and I can't put into the Image Area object
uva tosca1.jpg
uva tosca1.jpg (16.14 KiB) Viewed 8180 times
cabernet franc.jpg
cabernet franc.jpg (21.96 KiB) Viewed 8180 times
no problem for you to show them I belive.

best
franco

Edit: name of the variable in quotes return this error: " (Chunk: no such object) near "tNomeFld" "
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Image not shown

Post by Klaus »

Buonasera Franco,
francof wrote:...Edit: name of the variable in quotes return this error: " (Chunk: no such object) near "tNomeFld" "
oh, sorry, I thought that was the NAME of the field and not a variable containing the name! 8)
That's why I also wrote: Object names in QUOTES! :D


Best

Klaus
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Image not shown

Post by francof »

no problem, Klaus.
using the prefix 't' in the name I have not specified that it was a variable and not a field.

thanks again, ciao

franco
Post Reply