Triggers: Difference between revisions

34 bytes added ,  2 December 2016
m
no edit summary
mNo edit summary
mNo edit summary
Line 161: Line 161:
; Inform the user: Keep the user informed. For instance, if a script is running in a synchronous phase, then a call to ''cancel()'' may make sense, but the user won't know what happened and what to do next unless you provide that information, probably via ''message()''.
; Inform the user: Keep the user informed. For instance, if a script is running in a synchronous phase, then a call to ''cancel()'' may make sense, but the user won't know what happened and what to do next unless you provide that information, probably via ''message()''.


; Debug your script: Of course, you can put calls to ''message("Your message")'' to help to test your script. To further assist, the ''log("Your message")'' global function can be used to send messages to a log without bothering the user about it. By default, the log is directed to the Android developer console; to have it directed instead to a file, go to Memento Settings under Debug and turn on Triggers Logs. You can set the location for the file, but by default, it will be in ''memento/logs''. Both messages from calls to ''log()'' and system log messages go into the log.
; Debug your script: Of course, you can put calls to ''message("Your message")'' to help to test your script. To further assist, the ''log("Your message")'' global function can be used to send messages to a log without bothering the user about it. By default, the log is directed to the Android developer console; to have it directed instead to a file, go to Memento Settings under Debug and turn on Triggers Logs. You can set the location for the file, but by default, it will be in ''memento/logs''. Both messages from calls to ''log()'' and system log messages, including JavaScript exceptions, go into the log.


; Permissions: Certain functions require special permissions; read '''''[[#Security|above]]''''' about that. One such function is ''libByName()''. Others include the file access and HTTP functions.
; Permissions: Certain functions require special permissions; read '''''[[#Security|above]]''''' about that. One such function is ''libByName()''. Others include the file access and HTTP functions.