[Feature Request] "Run Action Group" as an Action

It would be very useful to have "Run Action Group" as an available choice when selecting an Action. This would allow Action Groups to call each other as "subroutines" and would make it much easier to construct complex processing sequences.

This might be a difficult request, but it depends on whether the Action processing code is already safely reentrant or not.

Thanks,

gvm

1 Like

You mean to combine several action groups together in a preferred order and give that a new name?

Which would enable to write common action groups only once and (re)use them in other action groups?

I absolutely second that feature request!

(could also be done by adding an additional hierarchical level to the action groups)

EDIT: in principle this can already be done by saving and loading (with the "utils" button in the action groups dialog).
This stores (and loads) the selection of the action groups; what's missing is to save/load the order of the groups...

kind regards,
Matthias

1 Like

Almost. The way I would see it working is that, when creating a new Action within an Action Group, there would be a new option in the "Select Action Type" drop down list, which would be something like "Run Action Group". It would take the name of the action group to run, as a parameter. This would allow Action Groups to be treated like subroutines. The "groups" that you refer to would be a new Action Groups, each composed of calls to other Action Groups, mixed in with other Actions if required.

The obvious(?) implementation involves a recursive call to the "Run Action Group", hence my comment about re-entrant code. I implemented something similar in another program, Long, Long Ago in a Computer Lab Far Far Away - the actual implementation is a lot simpler than it sounds.

Just to illustrate (and I'm not trying to tell Florian how to code! :slight_smile: - this is just for other "interested parties" and to clarify what I mean) - the implementation goes something like this. Assuming that there's a routine somewhere in MP3Tag that processes an Action Group specified as a parameter, we insert an extra "ActionGroupAsAction" line to make it look something like this:

Function ProcessActionGroup(ActionGroupName, Parameter1, Parameter2, Parameter3);

  Select On ActionGroupName
      Format:                 <format Parameter1>;
      Replace:                <replace Parameter1 with Parameter2>;
      ReplaceWithRegEx:       <replace regex Parameter1 with Parameter2>;
      ActionGroupAsAction:    ProcessActionGroup(Parameter1, Parameter2, Parameter3, Null);
   End Case
End Function

(written in ObviousCode ™).

Note that the ActionGroupAsAction line passes the incoming Parameter1 to ProcessActionGroup as the new ActionGroupName parameter, so it "calls" the named Action Group.

In Real Life™ it's not quite so trivial, there are issues with typing, etc., and the code has to all be re-entrant (suitable for recursion - no global variables), but I hope this illustrates the idea - it's also a good classroom example of how to use recursion effectively.

Yes - that's the objective.

Kind of - by doing it recursively, you can add an infinite number of levels of hierarchy - Each Action Group can contain calls to other Action Groups, which in turn call more Action Groups, etc. There would need to be a depth limit specified, though, in order to prevent accidental infinite recursion which would hang the program.

Almost, but not quite - '"Run Action Group" as an Action' would allow you to write one Action Group that can then be inserted into others (potentially nested) - this is far more powerful than just being able to (manually) load and save sequences.

Regards,

gvm

Actually, I over-simplified this - there would be 2 routines, one processing actions, one processing groups, with the two becoming mutually recursive:

Function ProcessActionGroup(ActionGroupName);
  ForEvery Action in Actiongroup(ActionGroupName)
    ProcessAction(ActionType, Parameter1, Parameter2, Parameter3);
  End For
End Function

Function ProcessAction(ActionType, Parameter1, Parameter2, Parameter3);
  Select On ActionType
      Format:                 <format Parameter1>;
      Replace:                <replace Parameter1 with Parameter2>;
      ReplaceWithRegEx:       <replace regex Parameter1 with Parameter2>;
      ActionGroupAsAction:    ProcessActionGroup(Parameter1);
   End Case
End Function

Regards,

gvm

I like this idea.

I would also like to suggest that each seperate action group is prefixed with its function if is single and that they can be moved up and down. (2.47b moving up and down does not appear to work- its stays alphanumeric)

I have attached an image of how I've sorted mine. This helps me find and remember which function I should use.

PS is there any way to combine quickly action groups together as two can not be edited at the same time?

Thanks


It work, but you have to save it after sorting: Utils (down left) > save

If you want to do simple copy & paste some actions into different groups, you might be a little bit faster if you do that directly in the .mta files at %appdata%\Mp3tag\data\actions with a text editor.

What happended to this request? Having an Action Type called "Run action group" to run another action in sequence and with the ability to nest these calls would take the whole processing to another level. This is almost so obvious that it took me a while to realise that it wasn't built-in by default.

PS: Thanks for the tip about Utils, bit clunky and can work as a workaround, but definitively not a replacement for a proper way to invoke action groups as per this request.