【问题标题】:how do i fix this error ,error "The variable bufferdName is not defined." number -2753 from "bufferdName"?我该如何解决这个错误,错误“未定义变量bufferdName。” “bufferdName”中的数字-2753?
【发布时间】:2017-03-19 00:03:04
【问题描述】:

我的 applescript 程序需要帮助

set UnixPath to POSIX path of ((path to me as text) & "::")
set term to get id of application "Terminal"
on notify(t)
    display notification t
end notify
notify("starting " & term)
to replaceText(someText, oldItem, newItem)
    (*
     replace all occurances of oldItem with newItem
          parameters -     someText [text]: the text containing the                             item(s) to change
                oldItem [text, list of text]: the item to be replaced
                newItem [text]: the item to replace with
      returns [text]:     the text with the item(s) replaced
 *)
set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, oldItem}
try
    set {itemList, AppleScript's text item delimiters} to {text items of someText, newItem}
    set {someText, AppleScript's text item delimiters} to {itemList as text, tempTID}
on error errorMessage number errorNumber -- oops
    set AppleScript's text item delimiters to tempTID
    error errorMessage number errorNumber -- pass it on
end try
return someText
end replaceText
on getMyName()
set myPath to path to me as text
if myPath ends with ":" then
    set n to -2
else
    set n to -1
end if
set AppleScript's text item delimiters to ":"
set myName to text item n of myPath
if (myName contains ".") then
    set AppleScript's text item delimiters to "."
    set myName to text 1 thru text item -2 of myName
end if
set AppleScript's text item delimiters to ""
return myName
end getMyName
set nameToFix to getMyName()
set bufferedName to replaceText(nameToFix, " ", "\\ ")
set lua to UnixPath & bufferdName & ".app/Contents/Resources/" & "lua"
set programSet to UnixPath & bufferdName & ".app/Contents/Resources/Scripts/lua_program.lua"
set mainComand to "program_app_temp/lua_program.lua"
set do to "dofile(" & quoted form of mainComand & ")"
tell application "Terminal"
activate
tell application "System Events"
    keystroke "mkdir ~/ai_app_temp"
    keystroke return
    keystroke "cp " & ai & " ~/ai_app_temp/"
    keystroke return
    keystroke lua
    keystroke return
    keystroke do
    delay 1
    keystroke return
end tell
end tell

当我运行我的程序时,它遇到一个错误并说 错误“未定义变量 bufferdName。”编号 -2753 来自 "bufferdName" 。我该如何解决?我是applescript的新手

【问题讨论】:

  • 这个问题与 Lua 有什么关系?
  • 我正在为 mac 计算机制作一个 独立 lua 软件启动器/解释器,因此编码人员不必总是使用 dofile(任何程序),它使用 mac命令提示符终端

标签: macos lua terminal applescript


【解决方案1】:

这看起来像是一个简单的拼写错误。仔细看这几行代码的拼写

set bufferedName to replaceText(nameToFix, " ", "\\ ")
set lua to UnixPath & bufferdName & ".app/Contents/Resources/" & "lua"
set programSet to UnixPath & bufferdName & ".app/Contents/Resources/Scripts/lua_program.lua"

bufferedName 是您设置的变量,但您使用的是 bufferdName

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-21
    • 2016-09-09
    • 2023-03-18
    • 2021-06-11
    • 2022-07-03
    相关资源
    最近更新 更多