I've written a couple macros that can go get the copied code and put it back in the proper place so that it's there for re-generation, so part of the work is done.
What I'd like to do is to hook in to File Open to detect this particular kind of file and do the Get function, then hook in to File Save to put the (potentially modified) copied code section back. This would allow me to edit the program much more seamlessly that I can currently.
I could attach the Save to Ctrl-S for instance, but I've no idea if that would work if I used File/Save from the menu or if the file was saved automatically before a compile, etc.
Any ideas? Obviously I could just remember to execute the macros, but not having to remember sure would be nice.
I may just have to resign myself to the occassional memory lapse and hope it doesn't cost me too much when it happens.
At one time there where plans to add macro triggers to Zeus but these where never implementedAny ideas? Obviously I could just remember to execute the macros, but not having to remember sure would be nice.
These triggers would be Zeus macros that provided they existed, would be run before/after specific Zeus events like File Open, File Save, File Close, Zeus Startup, Zeus Exit etc.
Would something like this be what you are looking for and if so which events would you need
The latest patch found here:
allows you to add macro hooks for the following events:
Code: Select all
[Triggers] FileOpenPrefix= FileOpenPostfix= FileClosePrefix= FileClosePostfix= FileCloseAllPrefix= FileCloseAllPostfix= FileSavePrefix= FileSavePostfix=
(2) The prefix hooks are called prior top the event and the postfix hooks are called after the event.
(3) The macros take zero or one argument as shown in the table below:
Code: Select all
Trigger Argument ====================================== FileSavePrefix Document Name FileSavePostfix Document Name FileOpenPrefix Document Name FileOpenPostfix Document Name FileClosePrefix Document Name FileClosePostfix None FileCloseAllPrefix None FileCloseAllPostfix None
Code: Select all
function key_macro() message_box(0, "This is open postfix macro!" .. "\n\nArguments: " .. argv(0), "Zeus Trigger Event") end key_macro() -- run the macro
I'm having trouble getting these to work. I have save.lua defined as:
-- save testing
message_box(0, "This is save postfix macro!" .. "\n\nArguments: " .. argv(0), "Zeus Trigger Event")
key_macro() -- run the macro
and saved in zScript.
I edit zeus.ini and change FileSavePostfix= to FileSavePostfix=save.lua
I then go to another open file and save it, expecting to see the message box. What I get is a status message saying the write was successful. Am I missing something?
Zeus also deletes the setting for FileSavePostfix, setting it back to the null string.
Whoops - spoke a little too soon. The macros are firing OK (per last post), but when I tried to compile a file that needed to be saved, I got an internal error. My live macro is hooked in to SavePostfix, and displays a status bar message on completion. I believe I saw it's message before the internal error popped up. I'm sending the log and dmp files to you via E-Mail. This appears to be repeatable, at least for me - it's done it 3 times in a row.
When I compile the same file without it's needing to be saved, it appears to go through the macro repeatedly until the compiler output window is displayed. I counted at least 10 times that I observed the completion message plus the file name tabs flashing while the macro did it's thing until the error list came up.
I don't know what was wrong yesterday, but it's working now.
Remember to not edit the zeus.ini using Zeus, because the INI file gets re-written on close, so your changes will be lost
I tried to replicate this but could notThis appears to be repeatable, at least for me.
What I did was define a simple message box save prefix macro and turn it on in the ini file. Setup the compile options to do a save all before each compile and then ran the compile several times without error
But I did find out that the files where being saved twice for each compile so one minor bug has been fixed
Once you get an internal error, Zeus will be in an unknown state, which means you generally get another internal error shortly after.it's done it 3 times in a row.
As a rule you should always restart Zeus after any internal error.
On the internal error, I did shutdown Zeus and restart between each attempt, and it did it 3 times in a row. I'm not sure if it's my save macro or just save macros in general combined with my compile. I run a CMD file to do a compile - I've never had any trouble with it so I have no real reason to suspect that as part of the problem.
My save macro finds a block of code in the file being saved, copies it to the clipboard, then opens another file, finds the equivalent code in it, pastes the (possibly revised) code in its place, saves and closes the second file, and goes back to the file being saved. It occurs to me that the save in a save postfix macro could be a problem - any ideas on how I might get away from that and still accomplish what I want to do?
This is one of the problems with these types of hooks. They introduce new program flows that aren't always obvious, offer up chances for new race conditions and provide yet another way for things to go wrongIt occurs to me that the save in a save postfix macro could be a problem - any ideas on how I might get away from that and still accomplish what I want to do?
I will put a lock on the trigger so that a trigger can’t be called from a trigger, which will at least eliminate the chance of infinite loops.
See my reply to your e-mail for suggestions on how I think your save macro should be restructured