2016-05-04 58 views
1

我想在LiveCode中將多個食物放入隱喻「籃子」中。如何創建數組/列表?

籃=「橙」,「蘋果」,「西紅柿」,「葡萄」]

這將如何在LiveCode做:我知道在Python這是這樣做呢?此外,我還希望LiveCode分離籃子中每個項目的所有字母。例如, 「o」,「r」,「a」,「n」,「g」,「e」...我該怎麼做?

回答

3

你不需要一個數組來滿足你的要求。您可以使用一個變量,像這樣:

put "orange,apple,tomato,grapes" into theBasket 

要檢索theBasket變量的內容,你引用其項目:

answer the items of theBasket -- answers the fruit names 

要檢索theBasket變量的一個項目:

answer item 3 of theBasket -- answers "tomato" 

獲取變量中的水果數量:

answer the number of items of theBasket -- answers 4 

你不解釋,你想每個水果單詞的字母做什麼,但你指的是單詞的字母字符(字符):

put item 1 of theBasket into theFruit -- puts "orange" into a new variable 
answer char 3 of theFruit -- answers "a" 

要了解實際LiveCode陣列,還有一些很棒的信息在這裏:http://revolution.byu.edu/arrays/introToArrays.php

+0

很好,謝謝你這麼多。 – CoopDaddio

+0

僅供參考,網站名稱已更新爲:http://livecode.byu.edu,儘管舊名稱仍作爲別名。 – Devin