sorry here is the same post with the code block inserted
Hello All,
Is it possible to combine 2 repeat statements?
Example:
property fruitList : {"apples", "oranges"}
property vegeList : {"lettuce", "broccoli"}
repeat with currentFruit in fruitList and with currentVege in vegeList
--do something example:
return currentFruit & currentVege
end repeat
This does not work, but i was wonder if it was possible. I don’t want to nest the second repeat. Is there a way to combine them?
property fruitList : {"apples", "oranges"}
property vegeList : {"lettuce", "broccoli"}
repeat with currentFruit in fruitList
repeat with currentVeggie in vegeList
display dialog currentFruit & " " & currentVeggie giving up after 1
end repeat
end repeat
Or maybe this is what you want:
property fruitList : {"apples", "oranges"}
property vegeList : {"lettuce", "broccoli"}
set total_count to (count fruitList)
if (count vegeList) > total_count then set total_count to (count vegeList)
repeat with i from 1 to total_count
try
set currentFruit to (item i of fruitList)
on error
set currentFruit to "?missing value?"
end try
try
set currentVeggie to (item i of vegeList)
on error
set currentVeggie to "?missing value?"
end try
display dialog ((i as string) & ". currentFruit = " & currentFruit & " currentVeggie = " & currentVeggie) giving up after 1
end repeat
Jonn8,
I basically want to get a server/share from an array and a connectionType from an array into the same string to mount the share. If i do a nested repeat it would not work right because my inner repeat would loop through my connectionTypes on the same server. I have an array if different servers.