2011-06-07 4 views
6

मेरे पास अलग-अलग लंबाई तारों की एक सूची है जो मैं लूपिंग कर रहा हूं:एप्पलस्क्रिप्ट में लूप की अनुक्रमणिका कैसे प्राप्त करें?

set my_list to {"abc", "defg", "hi", "jklmno"} 

repeat with the_item in my_list 
    -- get index of the_item 
end repeat 

मैं लूपिंग के दौरान_item की अनुक्रमणिका कैसे ढूंढ सकता हूं?

उत्तर

13

आप एक काउंटर लागू कर सकते हैं या तो और पाश के माध्यम से एक यात्रा के साथ अपडेट:

set counter to 0 
repeat with the_item in my_list 
    set counter to counter + 1 
    -- do stuff 
end repeat 

या एक different loop form का उपयोग करें:

repeat with n from 1 to count of my_list 
    -- do stuff with (item n of my_list) 
end repeat 
+0

टूटी लिंक? ऐप्पल समर्थन के लिए रीडायरेक्ट। –