Applescript:Logging System Event in a";如果/否则“;陈述可能的

Applescript:Logging System Event in a";如果/否则“;陈述可能的,applescript,Applescript,在Applescript中,是否可以在If/Else语句中登录 set x to 20 log "Log something" if 10 > x then return "10 is greater than " & x log "something else" else return "10 is not greater than " & x log "something else still" end if 在上面的示例中,事件日

在Applescript中,是否可以在If/Else语句中登录

set x to 20
log "Log something"

if 10 > x then
    return "10 is greater than " & x
    log "something else"
else
    return "10 is not greater than " & x
    log "something else still"

end if
在上面的示例中,事件日志记录“logsomething”,但if/else语句中的其他日志都不记录,即使满足条件且“return”有效


提前谢谢

语句让脚本立即离开并返回值。
log
-语句未执行;-) 只需在返回之前更改顺序和日志:-)

享受,
Michael/Hamburg

感谢@ShooTerKo修复了这个示例,但在我的实际源代码中,它仍然不起作用。嵌套if/else语句时是否不同?否。。。您可以设置变量的值,而不是返回。在您的示例中,您可以编写
将returnValue设置为“其他东西”
等。在脚本或处理程序的末尾使用
returnValue
。因此,您的脚本或处理程序将始终运行到最后!如果没有关于代码的更多信息,就很难获得更多帮助。也许你的问题是完全不同的,比如if/else中的逻辑错误。。。!?现在一切都好了。我试图在一个“告诉应用程序”中登录到控制台。它不起作用了。我只是在tell应用程序中创建了一个变量,然后在结束tell之后记录了该变量!