Hi, Jussi
Is there a way to determine how a macro was invoked? Specifically, from the Execute Macro Script window, or from a keyboard mapping? It would also be useful to be able to tell WHICH key was used to invoke the macro.
My specific use is to combine my 4 error display macros into one, since there are only relatively minor differences between them and that would make the code easier to maintain.
It's quite possible that I'm trying to solve this problem the wrong way. I'll also see if I can get the LUA loadfile function to work for me as a means of accomplishing my objective, but the invocation key still seems like a potentially useful bit of data.
Bill Diener
Macro invocation key
Hi Bill,
From the keyboard the answer is no.
For example:
For more details search for the argv and argc macro functions.
To better share the common code you could create a base macro file containing the common code and then include that file into the other, now much smaller macro files.
There is aslo the dofile Lua function. See the uncomment.lua for details.
Cheers Jussi
Is there a way to determine how a macro was invoked?
From the keyboard the answer is no.
From inside the Execute Macro Script window you can pass arguments to the macro.Specifically, from the Execute Macro Script window
For example:
Code: Select all
MyScript.lua argument1 argument2 argument3 ....
Code: Select all
My specific use is to combine my 4 error display macros into one
Code: Select all
I'll also see if I can get the LUA loadfile function
There is aslo the dofile Lua function. See the uncomment.lua for details.
Cheers Jussi
I've used argc and argv with event triggers, but never from the execute window. A useful thing to know...
This is probably a dumb question, but how do I "include" a macro function in another one? That would be fine with me, but I couldn't see a way to do it.
I know about dofile, and that would work if the code is organized a certain way. I got fixated on a "function library" approach and that didn't quite meet that criterion. I couldn't get loadfile to work for me - probably a shortcoming in my understanding of LUA.
Bill
This is probably a dumb question, but how do I "include" a macro function in another one? That would be fine with me, but I couldn't see a way to do it.
I know about dofile, and that would work if the code is organized a certain way. I got fixated on a "function library" approach and that didn't quite meet that criterion. I couldn't get loadfile to work for me - probably a shortcoming in my understanding of LUA.
Bill
You can also provide arguments in the Macro section of the document type.but never from the execute window. A useful thing to know...
As copied from the zScript/uncomment.lua macro:This is probably a dumb question, but how do I "include" a macro function in another one?
Code: Select all
dofile ("commentText.LUA") -- #include file
I know about dofile, and that would work if the code is organized a certain way.
That is Lua's include

Cheers Jussi
OK, I guess I got hung up on the "load and execute" description of dofile, since I didn't want to execute at the time I loaded. But again, perhaps my LUA understanding is a bit too shallow. I've written quite a few macros now, but I don't really feel like I understand the deeper aspects of the language.
In any event, that works perfectly for what I need. Thanks!
I still think a "How did I get here" macro function would be useful, but I don't have any immediate pressing need for it and it's not really very hard to live without.
Bill
In any event, that works perfectly for what I need. Thanks!
I still think a "How did I get here" macro function would be useful, but I don't have any immediate pressing need for it and it's not really very hard to live without.
Bill