Page 1 of 1

Why global variable can't be used as a function argument?

Posted: 06 Nov 2018 06:49
by beelze
I'm new in AM, so maybe I just missing a some vital concept, but here's a problem:

Tried to use condition expression like

Code: Select all

matches(join(somelist, ","), global_var)
but it always evaluates as false (global_var is a string ".*text").

But putting the same regex as string literal:

Code: Select all

matches(join(somelist, ","), ".*text")
working as expected. I'm puzzled :shock:

Re: Why global variable can't be used as a function argument

Posted: 07 Nov 2018 02:09
by Desmanto
I can replicate your problem once. The global_telkampret (I have created after Automagic 1.36.0), change it to string .*text. And suddenly it changes itself to number 1 after the script execution. Don't know why. After assigning the value directly in script

Code: Select all

global_telkampret = ".*text";
matches("hello,adsf,text", global_telkampret);
use that directly, it works. But if I comment that line (since the glovar has been saved), again, it changes itself to 1 after execution.

Assigning temporary variable to it also doesn't matter.

Code: Select all

a = global_telkampret;
matches("hello,adsf,text", a);
This still produce the same error, global_telkampret changes to 1 after execution.

However using the exact same script but with global_widget, same string type, no problem at all. global_widget was created long long time ago. So it seems something is off with the glovar creation.

Then I just remembered I have used this glovar somewhere, not a temporary glovar anymore. And yes I used it in a working flow as the marking for state :D The script change the glovar to 1 when it change to something else. Hence explained the mysterious behaviour. You should search for the global_var in your flow and see if there something changing it to another thing.

Re: Why global variable can't be used as a function argument

Posted: 07 Nov 2018 07:45
by beelze
Your guess was close.

Autocorrection has corrected <.> to <. >, which was not noticeable before I catched it in log :-)