question about loops

which is better memory wise

repeat - until
while - do - end
if - then - end
for - do - end

or does it matter
i know that sometimes you may have only one choice for the situation but if you were able to any to get the required result is one better then the other

do you know the limits for your loops?

repeat until will run atleast once
do while will run zero or more times
if then is *NOT* a loop
for end will run for a fixed range

so see what your requirements are and base it accordingly

cheers,

?:)

yeah a know if then not a loop but
I have a function that I need to loop an unknown amount of time and was wondering if it made a difference on memory usage
I could say if condition not true then rerun function or
repeat until condition not true or
while condition true do or
for 1, condition do

in other words I could make any of them do what I need but memory wise which is better

you have the answer to your own question.

you have an unknown amount, so the only options you have are

do..while
repeat..until

the only thing you need to now know is if there is a scenario where you do not wish this to run at all, if that is the case then you will use do .. while, but if you want this to run atleast *once* then you will use repeat .. until

memory wise, I think both are kind of equal.

cheers,

?:)

thanks

views:1247 update:2011/10/5 8:48:05
corona forums © 2003-2011