我想在LiveCode中将多个食品放入一个隐喻的“篮子”中。我在Python中知道这是这样做的:
basket = [“orange”,“apple”,“tomato”,“grape”]
如何在LiveCode中完成?此外,我还希望LiveCode将篮子中每个项目的所有字母分开。例如, “o”,“r”,“a”,“n”,“g”,“e”......我该怎么做?
答案 0 :(得分: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