macos AppleScript 编辑器,将消息写入“结果”窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2749863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:55:28  来源:igfitidea点击:

AppleScript Editor, write message to the "Result" window

macosloggingapplescript

提问by topskip

I am using the Mac OS X Apple Script Editor and (while debugging) instead of writing a lot of display dialogstatements, I'd like to write the results of some calculation in the window below, called "Result" (I have the German UI here, so the translation is a guess). So is there a write/print statement that I can use for putting messages in the "standard out" window? I am not asking to put the messages in a logfile on the file system, it is purely temporary.

我正在使用 Mac OS X Apple 脚本编辑器和(在调试时)而不是编写大量display dialog语句,我想在下面的窗口中编写一些计算的结果,称为“结果”(我在这里有德语 UI ,所以翻译是猜测)。那么是否有一个写入/打印语句可用于将消息放入“标准输出”窗口中?我不是要求将消息放在文件系统上的日志文件中,这纯粹是临时的。

回答by Paul R

You can use the logcommand, which puts messages into the Log Historywindow, e.g.:

您可以使用log命令,它将消息放入日志历史记录窗口,例如:



enter image description here

在此处输入图片说明

回答by cage

Log is the correct way of doing this; however, if your user base is more familiar with shell script you can do the following.

日志是这样做的正确方法;但是,如果您的用户群更熟悉 shell 脚本,您可以执行以下操作。

set val to 123
do shell script "echo The value: " & val

Output

输出

Result:
"The value: 123"

With this approach you don't constantly have to telling users that they need to enable ‘Show Log'

使用这种方法,您不必经常告诉用户他们需要启用“显示日志”