What I want to do is group 5 items and then have a return after those. Basically I want a group of 5, then a return. I don’t know the total number of items (totalNum) and that’s why I can’t use repeat or some other easier way of doing this.
Can you guys help me figure out what’s wrong or a better way of doing it?
set totalNum to 25
set itemCount to 1
set desktopPath to path to desktop as string
set fileID to open for access desktopPath & "testloop2.txt" with write permission
write "" to fileID starting at eof
repeat with i from 1 to totalNum
if itemCount is not equal to 5 then
set writeCode to i as string
write writeCode & ", " to fileID
set i to i + 1
set itemCount to itemCount + 1
else
write return to fileID
set i to i - 1
set itemCount to 1
end if
end repeat
close access fileID
Gives me this result:
It skips numbers, I can’t have that happen.