Option Dialog return code

Dm114

Well-known member
Option Dialog is a convenient way to select 1 button out of 3 to answer a question. But it's not easily possible to know which one of the 3 buttons has been pressed and you generally have to create from 1 to 3 different macros or action blocks to execute the specific actions involved by the choice you just made.

This very simple Action Block allows to get a return code in 2 ways: either a numerical value to indentify which button has been pressed or a specific text, or both of them.

Now you can assign a UNIQUE Action Block to EVERY buttons of ALL your Option Dialog boxes and just enter the values (integer and/or string) you want to retrieve, i.e. to get a "Return code" of 1 for the left button, enter this value as input in the configuration parameters of the DialogOption action block.

Try the example below to fully understand and... enjoy!

⚠️ A temporary bug prevents from entering negative numbers in the Configure parameters of the Action Block... So it's not possible yet to enter values such as (-1, 0, 1) as numerical values for buttons (left, center, right). In this example, (1, 0, 2) are used instead.

 

Dm114

Well-known member
Where is the action block located? In the link I only see the test macro.
Just for me to understand (and explain the bug to @MacroDroidDev): did you run the macro (the 1st time) and what happened?

What were the configuration Option Dialog and Configuration parameters showing?
 

Qarboz

Well-known member
Just for me to understand (and explain the bug to @MacroDroidDev): did you run the macro (the 1st time) and what happened?

What were the configuration Option Dialog and Configuration parameters showing?
Only show Option Dialog with the 3 button, but after click on any button nothing other effect, and the variables not change (i=0 and s=<empty>)
 

Qarboz

Well-known member
@Endercraft is probably right. I guess the Action Block wasn't exported because it is included in an Option Dialog

I added a line with the "OptionDialog" action block apart, at the bottom of the macro. Hope it'll work fine...


Thanks for your support. 🙏
Now the action block is included in the macro, however in order to make it work I had to reconfigure the Option Dialog.
Anyway, great job ;)
 

Dm114

Well-known member
Now the action block is included in the macro, however in order to make it work I had to reconfigure the Option Dialog.
Anyway, great job ;)
Really sorry for the inconvenience. ☹️

Here are the screenshots you shoud have had...

20240204_144908.jpg20240204_144823.jpg20240204_144755.jpg20240204_144715.jpg
 

Dm114

Well-known member
Yes, after I configured the dialog option it worked that way.
However I think it is a bug of MacroDroid's macro export, you are not at fault ;)
Yes it's a problem at export time but I even think it is specific to Option Dialog action...
 
Top