Python macro misbehaves when called via the keyboard
Posted: Thu Dec 16, 2004 6:04 am
Hi Jussi
I wrote a Python macro, which works perfectly when you call iy from the macro menu.
Eventually I worked out how to get rid of all the default macros so I could try calling it using the Shift+Alt+F1 key combination. But when I do this the macro misbehaves
Can you suggest anything that is a common gotchya for newbies when doing this.
In case it iis useful in diagnosing this the macro script is
import zeus
def key_macro():
zeus.screen_update_disable();
# mark the function name
zeus.MoveLineHome();
zeus.MarkBlockSet();
zeus.MoveWordNext();
zeus.MarkBlockReset();
# create the header
zeus.MarkCopyEx();
#zeus.MoveLineUp();
zeus.MoveDocumentStartEx();
zeus.write("//\n");
zeus.write("// ");
zeus.MarkPasteEx();
zeus.write("\n");
zeus.write("//\n");
descLine = zeus.get_line_pos();
zeus.write("// description\n");
zeus.write("//\n");
zeus.write("// Parameters\n");
zeus.write("//");
zeus.TabSmart();
zeus.write("None\n");
zeus.write("//\n");
zeus.write("// Returns\n");
zeus.write("//");
zeus.TabSmart();
zeus.write("Nothing\n");
zeus.write("//\n");
zeus.write("// Changes\n");
zeus.write("//\n");
zeus.write("//\n");
# select the description word so editing can begin
zeus.set_line_pos(descLine, 3);
zeus.MoveWordNextEx();
zeus.MarkBlockSet();
zeus.MoveWordNext();
zeus.MarkBlockReset();
zeus.screen_update_enable();
zeus.screen_update_enable();
zeus.screen_update();
key_macro() # run the macro
THe way to use it is to place it on a line that has a single word on it, the word should start at the first character position. Essentially it generates a function header comment for the name.
Thanks
john
I wrote a Python macro, which works perfectly when you call iy from the macro menu.
Eventually I worked out how to get rid of all the default macros so I could try calling it using the Shift+Alt+F1 key combination. But when I do this the macro misbehaves
Can you suggest anything that is a common gotchya for newbies when doing this.
In case it iis useful in diagnosing this the macro script is
import zeus
def key_macro():
zeus.screen_update_disable();
# mark the function name
zeus.MoveLineHome();
zeus.MarkBlockSet();
zeus.MoveWordNext();
zeus.MarkBlockReset();
# create the header
zeus.MarkCopyEx();
#zeus.MoveLineUp();
zeus.MoveDocumentStartEx();
zeus.write("//\n");
zeus.write("// ");
zeus.MarkPasteEx();
zeus.write("\n");
zeus.write("//\n");
descLine = zeus.get_line_pos();
zeus.write("// description\n");
zeus.write("//\n");
zeus.write("// Parameters\n");
zeus.write("//");
zeus.TabSmart();
zeus.write("None\n");
zeus.write("//\n");
zeus.write("// Returns\n");
zeus.write("//");
zeus.TabSmart();
zeus.write("Nothing\n");
zeus.write("//\n");
zeus.write("// Changes\n");
zeus.write("//\n");
zeus.write("//\n");
# select the description word so editing can begin
zeus.set_line_pos(descLine, 3);
zeus.MoveWordNextEx();
zeus.MarkBlockSet();
zeus.MoveWordNext();
zeus.MarkBlockReset();
zeus.screen_update_enable();
zeus.screen_update_enable();
zeus.screen_update();
key_macro() # run the macro
THe way to use it is to place it on a line that has a single word on it, the word should start at the first character position. Essentially it generates a function header comment for the name.
Thanks
john