>>Not so. This is a very simple thing I posted above. In such a simple case, the other cases would be handled differently. You'd need strings bigger than 100 chars before len would be slower and then for all the people who say m. is not important, the differences are not important enough to suggest that doing the conditional check in the loop is better most of the time.
>
>I still wonder why would
>
>>lcString = left(m.lcString,len(m.lcString)-1)
>
>be better than
>
>lcString = trim(m.lcString,1, ',')
It's not better. Your way is better than mine every time in my testing. len() is just a habit of mine and one that isn't even clear/obvious. trim/rtrim is the obvious, except it used to do just spaces at one time? I'll upgrade myself! :)
With bigger strings around 1000 chars, the conditional adding of the comma to the end is better. Below 100 chars the unconditional add is better. I've never concatenated 1000 char items into a comma delimited string. :) Just change kcString below to try different lengths.
kcString = REPLICATE("a",100)
a=SECONDS()
FOR y = 1 TO 100000
lcstring = ""
for x = 1 to 10
lcString = m.lcString + kcString + ","
endfor
lcString = left(m.lcString,len(m.lcString)-1)
ENDFOR y
?"unconditional",SECONDS()-m.a
a=SECONDS()
FOR y = 1 TO 100000
lcstring = ""
for x = 1 to 10
lcString = m.lcString + kcString + IIF(m.x=10,"",",")
endfor
ENDFOR y
?"conditional IIF",SECONDS()-m.a
a=SECONDS()
FOR y = 1 TO 100000
lcstring = ""
for x = 1 to 10
lcString = m.lcString + kcString
IF m.x=10
lcString = m.lcString + ","
ENDIF
endfor
ENDFOR y
?"conditional just IF",SECONDS()-m.a
a=SECONDS()
FOR y = 1 TO 100000
lcstring = ""
for x = 1 to 10
lcString = m.lcString + kcString + ","
endfor
lcString = rtrim(m.lcString,1,',')
ENDFOR y
?"trim",SECONDS()-m.a
Thanks!