Page 1 of 2

User-defined Templates?

Posted: 06 Oct 2017 22:49
by 98b427af
Is it possible to define my own templates and have them appear in the template list? If not, can we get that feature?

Thanks!

Re: User-defined Templates?

Posted: 06 Oct 2017 22:51
by 98b427af
Me too. ;)

Re: User-defined Templates?

Posted: 07 Oct 2017 16:58
by Desmanto
I think Martin is going to add it more to the next version. I want the multi trigger parallel expression template. So far, I made it using another helper flow.

But maybe the better one is to have the shortcut to our favourite elements. Now I am designing new helper flow and widget, so it will appear when adding new element. Tapping at the widget will use control UI to immediately select my favourite elements, such as : script, expression, Control UI, Notification on Screen, Debug Dialog, etc. The hardware acceleration for flow editor in version 1.34.0 really helps to reduce the delay. The sleep can be as low as 50ms, and still catch up with the Control UI execution.

Re: User-defined Templates?

Posted: 08 Oct 2017 16:25
by 98b427af
I haven't looked into alternate methods for this. At present I have a "flow" that contains a number of template patterns. To use them I copy/paste. I'm not particularly interested in developing my own or implementing someone else's solution to this now that templates are native - I've done a large amount of work on things like variable scope and, while I do enjoy that sort of thing, it can be tedious.

Re: User-defined Templates?

Posted: 08 Oct 2017 17:14
by Desmanto
Of course I also wish to create my own template too. Since everyone style of creating flow will be different.

I have finished my helper flow for favourite elements. It actually took not more than 30 minutes, but the thinking part maybe around several hours. :D So far, this will be my workaround for quick shortcut to my favourite elements.

Re: User-defined Templates?

Posted: 10 Oct 2017 09:40
by Martin
Hi,

Would this feature work like copy/paste? For example, you would create a template flow with a few actions and conditions and mark this flow as a template. Automagic would then list this flow under templates and adding the template would paste the actions/conditions to the new flow?

Regards,
Martin

Re: User-defined Templates?

Posted: 10 Oct 2017 14:15
by 98b427af
It could work like that, but that would clutter up the flow list with one flow per template. Currently, I have a single (disabled) flow with several action/condition sequences that I'm using for templates. So being able to mark such "parts" as templates right where they are would be better.

Or...

The app currently stores it's built-in templates somewhere unavailable to the user. Making that available for editing, or copying selected actions to that place (add a "copy as template" to the "copy" and "delete" for selected actions), might be the way to go.

In any case, the ability to add and delete templates to the built-in template storage would be the minimum necessary. Including editing in that would be ideal.

Re: User-defined Templates?

Posted: 10 Oct 2017 15:27
by Desmanto
@Martin : I agree with template group of flow. Taking up one group space solely for template is fine for me. So the template can be exported as xml too, can be shared as well. However, need to know how to solve the problem after adding too many templates. We will have a long scroll list which defeat the purpose of the template. I have 10 favourite elements currently, all adding only single element. Maybe this can be added as new menu in Add... ? So we have Action, Condition, Note, Template and Favourites (I know this is new request then, but I think I can mention it here).

For the template, beside of copy paste, I wish it can accept and parse variables too. Since it is almost a complete flow, i think it can be done. For example, I have several helper flow. One of them I have mentioned before, to create expression which check for multiple triggers. My flow function works by parsing all possible triggers from the flow (example there are 10 triggers). Then there will be input option showing those 10 triggers where I can choose only several of them, example I choose trigger 4, trigger 6 and trigger 8. After adding new element, my helper flow will use control UI and create a new expression which contain

Code: Select all

containsElement(newList("trigger 4", "trigger 6", "trigger 8"))
So this expression simply allow only trigger 4, 6 and 8 to pass thru it. The name of trigger 4, 6, 8 are parsed from the selected trigger those we choose from the flow.

So the template can use the variable derived from the previous elements, and we can choose to map them to the selected variable when adding the template. For example, previous element before the template have variables : {text}, {value} and {clip}. Then in the template we can defined a script to mention something like

Code: Select all

message = "{tempvar_a} {tempvar_b} has the clipboard of {tempvar_c}";
When adding the template, it will prompt us to map the variable. So we map/choose
tempvar_a >> text
tempvar_b >> value
tempvar_c >> clip

After pressing OK, the script will be created and has the content

Code: Select all

message = "{text} {value} has the clipboard of {clip}";
So the variable are dynamically replaced by the one we choose.

Sounds complicated :) But if it is going to be implemented, I think it should have this feature directly from the beginning. As adding it later will make all previously created template incompatible. Need to redesign the whole template logic again.

@98b427af : There are two possible solution. One is still the same, keep template as a group. But add a new level subgroup. Currently we have only group, then immediately flow. Only 2 levels. If we can add extra level, we can have group - group - flow. Template can be store as one 1st level group, and inside it we can have more 2nd group, and then the real template flow. How about it? I think extra level should be added now. I started to run out of space to keep the whole group in single screen :) even though I have parallel a lot of my one trick pony flow.

Second choice is to treat the template as a separate entity, such as widget or glovar. So the template located just below GloVar. And inside we can add as many parts as we want, ready to be pasted on any flow we want.

Re: User-defined Templates?

Posted: 12 Oct 2017 19:43
by Martin
I agree that the dynamic variable replacement would be a good thing. I just have to think about this some more so that the feature is flexible enough and yet not too complicated to use. Maybe it would be better not to replace the script when the template is inserted but just to map the variables to the expected ones (maybe that's also what you meant).
This also brings me to the idea to extend action Execute Flows to allow passing a few selected variables with different names to the executed flow and a way to define that a sub-flow only returns a few selected variables back to the parent flow. This could also help to extract some common actions and procedures into a helper sub-flow. This has the advantage that the actions and conditions in the sub-flow/template don't have to be copied into the parent flow. This would allow to improve the sub-flow/template without the need to rebuild every flow that uses the sub-flow/template. Maybe Automagic could also offer to 'inline' such a sub-flow/template into the parent flow in case one wants to customize the template heavily.

Unfortunately I'm busy implementing other stuff at the moment so this template feature is likely not going to become available in the next few weeks.

Regards,
Martin

Re: User-defined Templates?

Posted: 13 Oct 2017 05:07
by Desmanto
Yes, no problem. This template is just helper anyway, we still can create it manually. So, for me, no need to be the first priority. The execute flow with parameter is much more important. Since the workaround (send broadcast) is not quite friendly for most user.

If execute flow can pass variables and can return some variables, then some of the template actually is not needed. But I still need the template of the multiple trigger expression. I have to share the flow later to give a better idea.

I don't get the "inline" flow. Do you mean adding the whole flow to the current flow just like the template and mapping the variable as we add it? For the modifiying script, it is not needed actually, as long as we can edit the content of the template.