错误号-1708尽管拆分字符串 [英] error number -1708 While splitting a string

查看:192
本文介绍了错误号-1708尽管拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下函​​数,它字符串分割:

I have the following function that does string splitting:

on splitText(aString, delimiter)
    set retVal to {}
    set prevDelimiter to AppleScript's text item delimiters
    set AppleScript's text item delimiters to {delimiter}
    set retVal to every text item of aString
    set AppleScript's text item delimiters to prevDelimiter
    return retVal
end splitText

当单独使用,它的工作原理确定

When used by itself, it works ok

日志splitText(HTTP://google.com | /Users/pistacchio/Desktop/google.jpg,|)

log splitText("http://google.com|/Users/pistacchio/Desktop/google.jpg", "|")

但是,当我我需要的范围内使用它,我得到一个 -1708 错误

But when I use it within the context I need, I get a -1708 error

tell application "Safari"
    activate
    repeat with row in linesToPrint
        log splitText("http://google.com|/Users/pistacchio/Desktop/google.jpg", "|")
    end repeat
end tell

linesToPrint 是一个字符串数组

任何帮助吗?

推荐答案

在使用处理程序从应用程序中告诉语句,你需要使用的术语<一个href=\"https://developer.apple.com/library/mac/#documentation/AppleScript/Conceptual/AppleScriptLangGuide/conceptual/ASLR_about_handlers.html#//apple_ref/doc/uid/TP40000983-CH206-SW1\">of我或<一个href=\"https://developer.apple.com/library/mac/#documentation/AppleScript/Conceptual/AppleScriptLangGuide/conceptual/ASLR_about_handlers.html#//apple_ref/doc/uid/TP40000983-CH206-SW1\">my以表明期​​限从你的脚本,而不是应用程序需要做的。

When using a handler from inside an application tell statement, you need to use the terms of me or my to indicate that the term is from your script, and not something that the application needs to do.

这篇关于错误号-1708尽管拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆