Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将多个Applescript变量传递给Ruby_Ruby_Variables_Applescript - Fatal编程技术网

将多个Applescript变量传递给Ruby

将多个Applescript变量传递给Ruby,ruby,variables,applescript,Ruby,Variables,Applescript,我正在编写一个Ruby脚本,它需要来自Applescript的一些变量。现在,我成功地一次抓住一个,但这似乎不雅观,而且可能很慢。例如: note = %x{ osascript <<APPLESCRIPT tell application "Evernote" if selection is not {} then set the_selection to selection if notebook of it

我正在编写一个Ruby脚本,它需要来自Applescript的一些变量。现在,我成功地一次抓住一个,但这似乎不雅观,而且可能很慢。例如:

note = %x{ osascript <<APPLESCRIPT
    tell application "Evernote"
        if selection is not {} then
            set the_selection to selection
            if notebook of item 1 of the_selection is (notebook named "Writing") then
                return HTML content of item 1 of the_selection
            end if
        else
            return ""
        end if
    end tell
APPLESCRIPT}

title = %x{ osascript <<APPLESCRIPT
  tell application "Evernote"
        if selection is not {} then
            set the_selection to selection
            if notebook of item 1 of the_selection is (notebook named "Writing") then
                return title of item 1 of the_selection
            end if
        else
            return ""
        end if
    end tell
APPLESCRIPT}

note=%x{osascript从AppleScript中获取多个值是最简单的部分。与其返回单个值,不如返回一个列表:


result=%x{osascript<看起来很方便。

这很好,只需一个语法更改:Applescript逐字解释“/n”,因此当你在编辑器中编译脚本时,它实际上会在那里添加一行。在Applescript中,“linefeed”是等效的。我使用了它,然后在Ruby脚本中按“/n”拆分,一切都很正常。