Set Stream Deck Button Title to Different Variables Inside of Nested If/Then/Else?

I had considered that local versus global variables could be the root of the problem, so I suppose I should just try converting those global variables to local variables to see what would happen.

That said, I doubt that this is the issue, and here is why. To the best of my knowledge, I am initializing those variables each time. The trigger I'm using is actually the receipt of a new MCU message so, if these macros are getting triggered, it's because new info is coming in. And I can see the changes in the data reflected in what I'm seeing in those variables in the bottom left corner of those actions. Also, for the if/then macro that I'm specifically asking about here in this thread, it has been correctly indicating a true or false condition for the given context I've been using to test. So it's hard for me to imagine how all of those things could be happening like they're supposed to if there were an issue with local versus global variables.

But, I should go ahead and try converting those variable to local, just to see what happens. Maybe there's something about this stuff that I don't understand?

No, I'm not placing the text display action within any other if/then. It's all by itself, so it should fire everytime.

The window DOES pop up in situations where there is a long name value assigned in the lookup table. It's just when there isn't a long name value assigned, that the window doesn't pop up. But that's what is confusing me. I can clearly see the correct MCU name value displayed at multiple places within these sets of macros. The MCU Name variable exists and is populated with the correct value. So I don't understand why the popup window won't fire to display that value?

That seems ... impossible. The text box has fixed text in it in addition to the variables, so it should always show up regardless of what's in the variables. If that box isn't displaying, then something above it in your macro is preventing the code from getting there.

I'd probably insert a debugger call further up in the macro and step through it, to see exactly why it's not getting to where it looks like it should get getting.

-rob.

I'm not sure what to say about it. I just know that the window pops up in "true" situations, and doesn't in "false" situations. And the display text in a window action isn't nested within an if/then action. So it ought to fire every time, but it apparently is not. I'm at a bit of a loss here.

FYI, I did go and change all of the variables to instance variables instead of global variables. I still get the same results.

I'll mess around with the debugger, but I'll need to first get a better understanding of how the debugger works. I haven't had need to use it up until maybe now.

It just lets you step through the macro as it runs. Just add a Start Debugger action early on, and you’ll see it appear onscreen. Click the large ‘x’ at top right to reveal variables while it’s running.

Something is jumping over that code, and it should be easy to see what’s happening when you go step by step.

-rob.

So I'm playing with the debugger and, from what I can tell, these sets of macros are quitting when the shell script is run to look up the long name based on the MCU name. So it's not setting a value for the variable InstanceInsert1LongName because it finds no value in the lookup table for that given MCU name. That's not surprising though, because I've known that there was no value that it would be able to find.

But, this also appears to be shutting down any of the subsequent macros from firing within this group, as the debugger shows no further action going on, from what I can tell. So it seems like it's getting to the shell script action, and then can go no further. I'm not sure why that is though.

So, do you have any thoughts on executing shell scripts and what happens when it doesn't find a value in a lookup table? That seems like where things are getting hung up and that would explain why the display text window isn't firing.

Use the gear icon at the right of the Shell Script action, and make sure it's not set to abort the macro on failure. That's probably the problem. (You can also view the log files, which will probably show the failure in the shell script step.)

-rob.

Ok. I still need to do some more testing, but that may have fixed it. I wasn't aware of the abort on failure thing. I need to read up on that. Also, I need to read up on the trim results feature too. I had been having some issues with spaces, and now I maybe know why. Thanks for the suggestion.

Yep; trim and abort on failure have tripped me up many times :).

-rob.