It looks like you're new here. If you want to get involved, click one of these buttons!
Matthias,
Let's say you have a file called "Some magical function.lym" and click Properties, you type "Some function" as the description and choose "Show in menu" > "file_menu.end" or whatever, the macro's slug (a.k.a. name, or path) ends up being something like "file_menu.macro_in_menu21". The number at the end is just some unique number.
I think however it's preferable to have something like "file_menu.some_function" -- i.e. the ".some_function" should either (A) come from the Description field (but with spaces and unusual characters substituted with underscores), or (B) perhaps there could be a field where the user can enter the "some_function" string.
The reason I ran in to this is, in an upcoming script which may go in the next version of TRT, I'd like to get a handle to some actions something like
a = menu.action("trt_menu.macro_in_menu21")
b = menu.action("trt_menu.macro_in_menu37")
...
However, by looking at how it assigns that final number, I am led to believe that the "21" or whatever is just the 21st macro in menu on MY system, but if another user copies my scripts into their macros folder, their number that refers to the same might be some other number, not 21. So, a secondary code can never know what the slug should be.
Out of (A) and (B) above, I think (A) is preferable.
What do you think? Or is there another way of doing it?
David
EDIT: Or, equivalently, there could be a way to look up the slug if you have the Description. A method in the AbstractMenu class like:
AbstractMenu#get_name(string path, string Description)
For example
menu.get_name("trt_menu", "Some function")
would return "macro-in-menu21".
I'm using "get_name" above because that seems consistent with other usages in RBA. But I think "name" may be confusing - it could also be thought to refer to the filename or the description. I guess "get_slug" would be less ambiguous but it's not consistent with existing RBA nomenclature.
Comments
Hah. Never mind. I answered my own question with the previous edit. It is of course possible to look up the slug if you have the description.
Hi David,
I did not use the macro name because macro names do not need to be unique. So there was a certain risk of name clashes. That's why it picks a unique name. Maybe I can use the macro name and make it unique in case of a name clash.
Matthias
Ah I see the reason now. I suppose what you suggested of using the macro name and then appending a number if there's a name clash would be nice. But, it still requires the person coding to run get_slug(path,title) to get the actual name, in case there is a number appended.
So, in conclusion, actually I don't think that is necessary - it doesn't cut down on the amount of effort required to get the slug and be 100% sure you have the right one. And, there is a good solution above.
A get_slug (or get_name or whatever) method would be nice syntactic sugar if you like to add it to RBA, but not necessary.
Thanks anyway for your consideration!
David