如何修复这个错误,错误 "The variable bufferdName is not defined." number -2753 from "bufferdName"?

我需要帮助我的 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

当我运行程序时出现错误,显示 error "The variable bufferdName is not defined." number -2753 from "bufferdName" 。我该怎么解决?我对 applescript 很陌生。

点赞
用户6844169
用户6844169

看起来这只是一个简单的拼写错误。仔细查看以下代码行中的拼写:

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 <-- 拼错了。

2017-03-19 01:48:13