如何创建一个array/list?
How to create an array/list?
我想在 LiveCode 中将多个食品放入一个比喻 "basket" 中。我知道在 Python 中是这样完成的:
篮子 = ["orange", "apple", "tomato", "grapes"]
如何在 LiveCode 中完成?此外,我还希望 LiveCode 将篮子中每个项目的所有字母分开。例如,
"o"、"r"、"a"、"n"、"g"、"e"...我该怎么做?
您的要求不需要数组。您可以使用变量,如下所示:
put "orange,apple,tomato,grapes" into theBasket
要检索 Basket 变量的内容,请引用其项目:
answer the items of theBasket -- answers the fruit names
检索购物篮变量的一项:
answer item 3 of theBasket -- answers "tomato"
获取变量中水果的个数:
answer the number of items of theBasket -- answers 4
你没有解释你想用每个水果词的字母做什么,而是把一个词的字母称为chars(字符):
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
我想在 LiveCode 中将多个食品放入一个比喻 "basket" 中。我知道在 Python 中是这样完成的:
篮子 = ["orange", "apple", "tomato", "grapes"]
如何在 LiveCode 中完成?此外,我还希望 LiveCode 将篮子中每个项目的所有字母分开。例如, "o"、"r"、"a"、"n"、"g"、"e"...我该怎么做?
您的要求不需要数组。您可以使用变量,如下所示:
put "orange,apple,tomato,grapes" into theBasket
要检索 Basket 变量的内容,请引用其项目:
answer the items of theBasket -- answers the fruit names
检索购物篮变量的一项:
answer item 3 of theBasket -- answers "tomato"
获取变量中水果的个数:
answer the number of items of theBasket -- answers 4
你没有解释你想用每个水果词的字母做什么,而是把一个词的字母称为chars(字符):
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