A neat loop can be very elegant and of course, if you have to change an equation, you only change it inside the loop.
If you have a very short number of elements - like 3 - is it faster to use indexing and array statements to deal with those three cases or faster to just define three things and statements that repeat, except for the variable, three times
For example - this is going to be way simple - if I have three names and I want to uppercase them, I could do:
name1 = upper(name1)
name2 = upper(name2)
name3 =upper(name3)
or set AllNames = name1 + “,” + name2 + “,” + name3
then:
x = 0
loop
x = x + 1
array(AllNames, 1, “,”) = upper(array(AllNames,1,“,”))
until x = arraysize(AllNames, “,”)
In the “real world” it looks more like:
yes - I know I could put that calculation in the if statement instead of using the dif variable
I could even put it in the rep( function if it is happy with a zero count
the point is, I can repeat the code below three times or build a 2-dimensional array with a CR() delimiter between what is now locate1, locate2, locate3
dif = maxfound - arraysize(locate1,“,”)
If dif ≠ 0
locate1 = locate1 + rep(“,”,dif)
endif
but the overhead of that construction may “cost” more than just repeating the code X (where X is your tolerance for repeat code statements) times?