Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/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上列表的每个项目运行子脚本_Applescript_Delimiter_Subscript - Fatal编程技术网

为AppleScript上列表的每个项目运行子脚本

为AppleScript上列表的每个项目运行子脚本,applescript,delimiter,subscript,Applescript,Delimiter,Subscript,我有一个列表,我想要这个列表中的每个元素(订单号) 要运行搜索,请从chrome抓取文本并使用此订单号浏览网站 我已经有两个脚本(A和B) 我想我可以把我的长脚本(B)添加到第一个脚本中 repeat with theItem in theResult Script B end repeat 但这不起作用,我得到了错误 应为“结束”,但找到“属性” 脚本B,例如: tell application "Google Chrome" tell front window's active t

我有一个列表,我想要这个列表中的每个元素(订单号) 要运行搜索,请从chrome抓取文本并使用此订单号浏览网站

我已经有两个脚本(A和B)

我想我可以把我的长脚本(B)添加到第一个脚本中

repeat with theItem in theResult
Script B
end repeat
但这不起作用,我得到了错误

应为“结束”,但找到“属性”

脚本B,例如:

tell application "Google Chrome"
    tell front window's active tab to set infoGrab to execute javascript "document.getElementsByClassName('even')[2].innerHTML;"
end tell

set theText to Unicode text
set theSource to infoGrab
property leftEdge72 : "<a href=\"/"
property rightEdge72 : "\">"
set saveTID to text item delimiters
set text item delimiters to leftEdge72
set classValue to text item 2 of theSource
set text item delimiters to rightEdge72
set uniqueIDKey to text item 1 of classValue
set text item delimiters to saveTID
uniqueIDKey
但是这也不起作用,因为脚本B忽略了所有的重复和延迟,只是在Google chrome上不做任何操作的情况下运行所有即时操作

问题:如何对列表的每个元素执行其他操作,包括文本分隔符等


PS:如果我的帖子让人困惑,很抱歉。

运行脚本别名((以文本形式指向桌面文件夹的路径)和“SEARCH.scpt”)

我认为您的脚本有缺陷,因为“脚本B”没有使用重复循环中的“ITEEM”变量。因此,“脚本B”将为每个项目返回相同的结果

您的目标不明确。如果您提供更多详细信息,并提供源HTML和预期结果的真实示例数据,我们可能会提供更好的帮助

IAC,你为什么要调用脚本而不是使用处理程序? 以下是经过重构以使用处理程序的脚本,作为示例

在结果中用item重复
##在脚本B中,您似乎没有使用“Iteem”##
#如果是这样,那么getID()处理程序将为此循环中的所有项返回相同的结果
将myID设置为my getID()
结束重复
在getID()上--是脚本B
--放入同一脚本文件或脚本库中
--这是否需要一个参数?
告诉应用程序“谷歌浏览器”
告诉前窗口的活动选项卡将infoGrab设置为执行javascript“document.getElementsByClassName('even')[2].innerHTML;”
结束语
将文本设置为Unicode文本
将源设置为infoGrab
将leftEdge72设置为“”
将saveTID设置为文本项分隔符
将文本项分隔符设置为leftEdge72
将classValue设置为源的文本项2
将文本项分隔符设置为rightEdge72
将uniqueIDKey设置为classValue的文本项1
将文本项分隔符设置为saveTID
返回唯一键
结束getID

你的标题暗示了答案。你必须告诉
myScript
运行是的,这很有意义,也很有效,谢谢你!但对我来说不幸的是,脚本be在几秒钟后就失败了(但单独运行时没有问题)
repeat with theItem in theResult
    set the clipboard to theItem
    set myScript to load script file ((path to desktop folder as text) & "SEARCH.scpt")
    tell myScript
    end tell
    delay 30
end repeat