我想使用两个简单的按钮单击来为“department”和“suite”生成变量。单击一次按钮应该根据“部门”的返回值创建另一组按钮选项为什么这不起作用?
--set up departments and suites
property departments : {"Audio", "Video", "Digital"}
property suites_Audio : {"A1","A2", "A3", "TXFR"}
property suites_Video : {"VFX1", "VFX2", "FCP1", "FCP2", "Flame1", "Flame2"}
property suites_Digital : {"MCR", "Encoding", "Store"}
--get suite location
display dialog "Enter your department" buttons departments
set department to button returned of the result
set suites to "suites_" & department
display dialog "Enter your suite" buttons {suites}
set suite to button returned of the result
我对这两行的语法有一种感觉:
set suites to "suites_" & department
display dialog "Enter your suite" buttons {suites}
因此,点击正确的部门应该会生成一组新的按钮,从顶部的套房属性中挖掘到右侧套房。
有人可以帮忙吗?
答案 0 :(得分:1)
您正在使用以下内容重置套件的价值:
set suites to "suites_" & department
尝试:
--set up departments and suites
property departments : {"Audio", "Video", "Digital"}
property suites : {{"A1", "A2", "A3", "TXFR"}, {"VFX1", "VFX2", "FCP1", "FCP2", "Flame1", "Flame2"}, {"MCR", "Encoding", "Store"}}
--get suite location
display dialog "Enter your department" buttons departments
set department to button returned of the result
set suite to first item of (choose from list item (my findOffset(department)) of suites with prompt "Enter your suite")
on findOffset(findItem)
repeat with i from 1 to (count departments)
if item i of departments = findItem then return i
end repeat
end findOffset