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 [import]uid: 7911 topic_id: 14550 reply_id: 314550[/import]

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,

?:slight_smile: [import]uid: 3826 topic_id: 14550 reply_id: 53923[/import]

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
[import]uid: 7911 topic_id: 14550 reply_id: 53925[/import]

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,

?:slight_smile: [import]uid: 3826 topic_id: 14550 reply_id: 53927[/import]

thanks [import]uid: 7911 topic_id: 14550 reply_id: 53929[/import]