首页 > 解决方案 > 在applescript中需要帮助编程按钮

问题描述

我试图在一个小程序的末尾添加一些按钮,当所有的事情都说完后,这将结束 uo 非常广泛。一旦程序运行,我想要 3 个按钮 {“显示公式”、“返回列表”、“退出”}

我不知道我在做什么哈哈,我在写这篇文章时基本上一直在谷歌搜索,我想我需要帮助

在按钮选项之后我有一些代码,但它一直给我“结束”错误。我删除了代码,我忘记了我必须向你们展示

这是我的代码

set x to item 1 of (choose from list {"Divers consumption at depth", "Free gas volume", "Price list"})
if x is "Divers consumption at depth" then
    display dialog "what is divers breathing volume (default 1.4 l/min?" default answer "1.4"
    set varDvol to text returned of result
    display dialog "What is divers absolute depth pressure" default answer ""
    set varPbar to text returned of result
    set answer to varDvol * varPbar
    display dialog "Diver consumption is " & answer as text buttons {"See formula", "Return to list", "Exit"}

我想要他们所说的按钮。显示公式按钮将显示“消耗=体积*压力”,如果需要执行另一个功能,返回列表将返回原始列表,退出将退出应用程序

标签: buttonapplescript

解决方案


您正在寻找这样的结构:

display dialog "Diver consumption is " & answer as text buttons {"See formula", "Return to list", "Exit"}
set response to button returned of result
if response = "See formula" then
    #do one thing
else if response = "Return to list" then
    #do a different thing
else if response = "Exit" then
    #do a third thing
end if

推荐阅读