Hi John,
I'm trying to write a script and have run into a problem on the first step
At first macros can be a little difficult but with a bit of practise they do get easier
Now I' m wondering if there is a zeus way of determining if there is a word at the start of the line
This Lua macro will test the current line for a space or a word and display the result in the status bar.
Code: Select all
function key_macro()
screen_update_disable()
-- get a copy of the current line
local text = get_line_text()
if (string.find (text, " ", 1, 1) == 1) then
message("Line starts with a space.")
else
message("Line starts with a word.")
end
screen_update_enable()
screen_update()
end
key_macro() -- run the macro
Or is the general philosophy to import things like standard libraries for the scripting language, python in my case, and use them. I know Python has routines to do this sort of thing.
This is definitely the Zeus philosophy. The Zeus scripting model provides a handfull of scripting interface functions to allow the language to interface with the current document. The real processing should be done using the scripting language. In the Zeus online help, use the index and search for
Macro, Builtin Functions. This section describes these scripting interface functions.
One of these interface functions is the
get_line_text function. The macro above is written in Lua but it could easily be re-written in any one of the other
Python, JavaScript etc scripting languages.
Cheers Jussi.