以下是一个使用AppleScript的示例,该示例在定义的列表中使用条件系统:
-- 定义列表
set myList to {"apple", "banana", "orange", "grape"}
-- 使用条件系统
repeat with itemValue in myList
if itemValue is equal to "apple" then
display dialog "I love apples!"
else if itemValue is equal to "banana" then
display dialog "I like bananas!"
else if itemValue is equal to "orange" then
display dialog "Oranges are tasty!"
else
display dialog "I don't know what to say about " & itemValue
end if
end repeat
在这个示例中,我们首先定义了一个列表myList
,包含了几种水果。然后,我们使用条件系统来检查每个列表项的值,并根据条件显示不同的对话框消息。
在repeat with itemValue in myList
循环中,我们遍历列表中的每个项。然后,我们使用if
语句来检查itemValue
的值。如果itemValue
等于"apple",则显示"I love apples!"对话框消息。如果itemValue
等于"banana",则显示"I like bananas!"对话框消息。如果itemValue
等于"orange",则显示"Oranges are tasty!"对话框消息。否则,显示"I don't know what to say about " & itemValue对话框消息,其中&
用于连接字符串。
请注意,在AppleScript中,条件比较使用is equal to
而不是==
或=
。