condition loop for image visibilty
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
condition loop for image visibilty
Hi!
i would like to check in an app i have made how many images are still visible, and then print the answer to the user.
what would be the most effcient way of doing it?
i was thinking about a loop with a condition only that i lack the knowladge of phrasing it in LC.
can someone give me a hand?
tnx
Tomer
i would like to check in an app i have made how many images are still visible, and then print the answer to the user.
what would be the most effcient way of doing it?
i was thinking about a loop with a condition only that i lack the knowladge of phrasing it in LC.
can someone give me a hand?
tnx
Tomer
Re: condition loop for image visibilty
Hi Tomer,
1. welcome to the forum!
2. Do you need the number of images on the current card or on all cards in the stack?
3. Here some great learning resources for the basics of Livecode:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
1. welcome to the forum!

2. Do you need the number of images on the current card or on all cards in the stack?
3. Here some great learning resources for the basics of Livecode:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
Re: condition loop for image visibilty
Hi.
The "visible" is a property of all controls. So your idea of a loop "with a condition" is exactly right. That "condition" is testing the property of each control.(pseudo:)
And as Klaus mentioned, do learn as you work, so your questions will be more useful to you.
Craig Newman
The "visible" is a property of all controls. So your idea of a loop "with a condition" is exactly right. That "condition" is testing the property of each control.(pseudo:)
Code: Select all
repeat with y = 1 to the number of controls either on this card or in the whole stack
if the visible of control y then add 1 to totalVisible
end repeat
Craig Newman
Last edited by dunbarx on Mon Mar 27, 2017 7:43 pm, edited 1 time in total.
Re: condition loop for image visibilty
hi guys!
thank u for replying my question - but yet im having a hard time finding the correct syntax for my problam.
here is what i am trying to do:
for a certain button, i would like to write a script that check how many of my images are still visible.
the images are all in the same card. finally it should print back to the user an answer for how many images are still visible.
how would you phrase it?
btw the tutorial u gave me is great, thank u for that!
Tomer
thank u for replying my question - but yet im having a hard time finding the correct syntax for my problam.
here is what i am trying to do:
for a certain button, i would like to write a script that check how many of my images are still visible.
the images are all in the same card. finally it should print back to the user an answer for how many images are still visible.
how would you phrase it?
btw the tutorial u gave me is great, thank u for that!
Tomer
Re: condition loop for image visibilty
Hi Tomer,
You can use a function that you can call from all btns like this
Best regards
Jean-Marc
You can use a function that you can call from all btns like this
Code: Select all
--••btn script
on mouseUp
deMyButton
end mouseUp
--•• cd script
on deMyButton
answer getNbImgVis()
end deMyButton
function getNbImgVis
put 0 into tCount
repeat with i = 1 to the num of imgs
if the vis of img i then add 1 to tCount
end repeat
return tCount
end getNbImgVis
Jean-Marc
https://alternatic.ch
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: condition loop for image visibilty
Code: Select all
on mouseUp
repeat with y - 1 to the number of controls on this card
if the visible of control y then add 1 to totalVisible
end repeat
put totalVisible
end mouseUp
Re: condition loop for image visibilty
thank you guysfor you help!
Re: condition loop for image visibilty
Just noticed that my earlier post, and Richmond's later take on it had:
instead, of course,
Craig
Code: Select all
repeat with y - 1 to..
Code: Select all
repeat with y = 1 to..