If statement not working
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
If statement not working
I am using inpart this stament to check if an image exist. :
put the imagedata of img "itemPic3" into tItemPic3
answer tItemPic3
if tItemPic3 is empty then
put empty into item 16 of line tNextFileNumber of tSavedFile
else
set the folder to specialFolderPath("documents")
create folder "myimages"
put specialFolderPath("documents") &slash&"myimages"&slash into tP
set the JPEGQuality to 100
export image "itemPic3" to URL ("file:" & tP&"myimages"&tTime3&".jpg") as JPEG
put tP&"myimages"&tTime3&".jpg" into item 16 of line tNextFileNumber of tSavedFile
end if
The issue I am having is that even when the tItemPic3 is empty the execution skips the empty exception statement.
Thank you
Ty
put the imagedata of img "itemPic3" into tItemPic3
answer tItemPic3
if tItemPic3 is empty then
put empty into item 16 of line tNextFileNumber of tSavedFile
else
set the folder to specialFolderPath("documents")
create folder "myimages"
put specialFolderPath("documents") &slash&"myimages"&slash into tP
set the JPEGQuality to 100
export image "itemPic3" to URL ("file:" & tP&"myimages"&tTime3&".jpg") as JPEG
put tP&"myimages"&tTime3&".jpg" into item 16 of line tNextFileNumber of tSavedFile
end if
The issue I am having is that even when the tItemPic3 is empty the execution skips the empty exception statement.
Thank you
Ty
-
- VIP Livecode Opensource Backer
- Posts: 4002
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: If statement not working
Hi Ty,
I don't think the imageData of an image is ever empty.
I created an empty image by dragging it from the Tools palette
then named it "itemPic3"
I don't know what condition makes your image "empty" or not empty. You could test for other values.
But maybe you explain what you do to image "ItemPic3" to make it empty or not empty.
Kind regards
Bernd
I don't think the imageData of an image is ever empty.
I created an empty image by dragging it from the Tools palette
then named it "itemPic3"
Code: Select all
on mouseUp
set the imageData of img "ItemPic3" to ""
put the imagedata of img "itemPic3" into tItemPic3
answer (tItemPic3 = "") && length (tItemPic3) && the milliseconds
end mouseUp
But maybe you explain what you do to image "ItemPic3" to make it empty or not empty.
Kind regards
Bernd
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: If statement not working
Hi Ty,
Gosh what a workaround!
In my testing it seems the imageData is never empty as long as there is a size to the image object.
Simon
Gosh what a workaround!
Code: Select all
put the formattedHeight of img "itemPic3" into tItemPic3
answer tItemPic3
if tItemPic3 is 0 then
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 4002
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: If statement not working
Hi Simon,
"formattedHeight" is a very nifty workaround.
The ones that came to my mind would have really been awful.
Kind regards
Bernd
"formattedHeight" is a very nifty workaround.
The ones that came to my mind would have really been awful.
Kind regards
Bernd
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: If statement not working
Thanks Bernd,
It was that imageData size thing that triggered it.
Simon
It was that imageData size thing that triggered it.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: If statement not working
I thought I pressed the send on this,
It appears that due to the fact that sometimes I am adding a new picture and other times I am keeping an existing picture that I need to check the filename and the image data to verify if that image is there. When it is a new image then I have and image data, but if I have a saved image on the card I have a file name. If both are empty then I can execute the correct statement and if one or the other is not empty then if makes the condition false and allowing the correct statement to excite.
Does that make since?
Ty
It appears that due to the fact that sometimes I am adding a new picture and other times I am keeping an existing picture that I need to check the filename and the image data to verify if that image is there. When it is a new image then I have and image data, but if I have a saved image on the card I have a file name. If both are empty then I can execute the correct statement and if one or the other is not empty then if makes the condition false and allowing the correct statement to excite.
Does that make since?
Ty
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: If statement not working
Hi Ty,
Except for an imported picture, it has no filename.
Now if you don't use imported picture then all you need is the filename.
imageData never seems to be empty, if there is an empty image object it will contain imageData even if there is nothing to see.
Simon
Except for an imported picture, it has no filename.
Now if you don't use imported picture then all you need is the filename.
imageData never seems to be empty, if there is an empty image object it will contain imageData even if there is nothing to see.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: If statement not working
Simon,
Great advise, I don't plan to import on this app, but will keep in mind for my other project. The point about the image data never being empty sure explains a lot.....
Thank you two for your help
Ty
Great advise, I don't plan to import on this app, but will keep in mind for my other project. The point about the image data never being empty sure explains a lot.....
Thank you two for your help
Ty
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: If statement not working
Simon,
I meant to type:
if the filename of image "itemPic1" is empty and image "itemPic1" is empty then, etc.
Thanks
Ty
I meant to type:
if the filename of image "itemPic1" is empty and image "itemPic1" is empty then, etc.
Thanks
Ty