<-- back to the index of Rosetta examples
hello world (text, log)
Create a new action hello() that prints "Hello world!" in the message log.
Example implementations
awk
|
bash
|
lua
|
pl
|
py
|
rb
|
scm
|
stt
|
tcl
Explanation, step by step
Load packages the script depends on:
-
actions
for registering the new action;
-
dialogs
for printing in the message log.
Create a function
ev_action
that will be called when any of the actions registered by the script is executed. The script registers only one action, so it does not need to check which action caused the function to be called.
When the action event is called, use
dialog_log
to append a log message.
In the "main" section of the script, bind event
ACTE_action
to our local function
ev_action
- this gets
ev_action
to be called when any of the actions registered by this script is executed.
Finally use
action_register
to register the action:
- first argument is the name of the action
- second is the xy query string; it is empty since this action won't need coordinates to operate on
- third is the description that shows up in dumps and helps
- fourth is the syntax description (also for helps)