Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Current File and Current Macro
#1
Is there a way to get the name of the current file and current macro playing, because in a single file, there can be multiple macros in them.


Thank you
#2
Code:
Copy      Help
str cmacro cfile
rget cfile "file" "software\gindi\qm2\settings"
cmacro.getmacro(getopt(itemid 3) 1)
out cfile
out cmacro

cmacro will contain the name of the macro executing this code.
#3
What about a macro calling a function? how can the function check the name of the macro?
#4
See Help, getopt.

Code:
Copy      Help
cmacro.getmacro(getopt(itemid 1) 1)
#5
Wow, you documentation is wonderful.

But I am new to this so please give me a little bit more time to understand, lol.

Anyways, do you already have a built in function that enumerates all the macros and functions in a file? I have organized my macros to go to "Macro" folder and all the Functions to go to "Functions" folder. So when I open the file, I only see 3 folders.

I am getting ready to distribute this file at work but I need to make sure that when the main macro is played, all the other macros and functions are in the file. And at this point, I am totally clueless how to check that Sad
#6
Yes, it is qmitem.

Code:
Copy      Help
QMITEM q; int i
rep
,i=qmitem(-i 1 q 1)
,if(i=0) break
,out q.name

Other way to ensure that a function exists - use #ifdef or #ifndef.
#7
Wow :lol: thank you very much.

How do I do it w/o the System Folder?
#8
Use flag 2 - skip shared.

Code:
Copy      Help
QMITEM q; int i
rep
,i=qmitem(-i 1|2 q 1)
,if(i=0) break
,out q.name
#9
Hello All,
I wrote a little function that can be put at the beginning of a function that outputs the current item (item from which is called this function) and the thread entry function (macro or function that started execution) ....

This was based on the above and something else in the forum which I can't find right now but also demonstrates how to use the context arguments of getopt in conjunction with getmacro, which can be a bit confusing.

Not sure yet what difference is between option 2 and 3.
Any thoughts or more elegant solutions, Gintaras?
S

Function OutCurrentAndThreadEntryMacros
Code:
Copy      Help
str cmacro tmacro;; current macro; thread entry macro,
tmacro.getmacro(getopt(itemid 3) 1);; thread entry function (macro or function that started execution)
cmacro.getmacro(getopt(itemid 1) 1);;current item (item from which is called this function)
out "------------------------[]Macro: %s called in thread: %s[]------------------------[]" cmacro tmacro
#10
3 is correct.
2 would get current callback function, if exists, for example dialog procedure.
#11
thanks!
S


Forum Jump:


Users browsing this thread: 1 Guest(s)