Macro invocation key

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
pwdiener
Posts: 134
Joined: Wed Jul 11, 2007 3:45 pm

Macro invocation key

Post by pwdiener » Thu Aug 02, 2012 5:35 pm

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

jussij
Site Admin
Posts: 2449
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij » Thu Aug 02, 2012 10:26 pm

Hi Bill,
Is there a way to determine how a macro was invoked?

From the keyboard the answer is no.
Specifically, from the Execute Macro Script window
From inside the Execute Macro Script window you can pass arguments to the macro.

For example:

Code: Select all

MyScript.lua argument1 argument2 argument3 ....
For more details search for the argv and argc macro functions.

Code: Select all

My specific use is to combine my 4 error display macros into one
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.

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

pwdiener
Posts: 134
Joined: Wed Jul 11, 2007 3:45 pm

Post by pwdiener » Thu Aug 02, 2012 10:36 pm

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

jussij
Site Admin
Posts: 2449
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij » Thu Aug 02, 2012 10:54 pm

but never from the execute window. A useful thing to know...
You can also provide arguments in the Macro section of the document type.
This is probably a dumb question, but how do I "include" a macro function in another one?
As copied from the zScript/uncomment.lua macro:

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

pwdiener
Posts: 134
Joined: Wed Jul 11, 2007 3:45 pm

Post by pwdiener » Thu Aug 02, 2012 11:25 pm

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

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 3 guests