Reading System Settings into a variable

fmcpma

Member
Hello all.

Now, I may be very stupid (hey, I heard that!) but I just can't seem to be able to get the list of magic texts to include the three System Setting entries – System, Global and Secure – when calling that list from the Set Variable dialogue. It seems to me that those entries appear in every other magic text list, called from every other dialogue, except from Set Variable, which is where it would be more useful to me.

For instance, I create an integer variable, I add a Set Variable action, then in the first dialogue I select the just-created variable, in the second dialogue I select the Expression option and in the third dialogue I press the […] button. A list of magic texts comes up which includes stopwatches, variables, Current Brightness, System time, etc., but no System Setting entry. The only way to assign a system setting to a variable that I can find is to copy that setting name from some other action's dialogue, after selecting it from that dialogue's magic text list, and then paste it into Set Variable. That works.

Any help appreciated.
 
Last edited:

Endercraft

Moderator (& bug finder :D)
That's because the value returned can be a string and not a number like 0 or 1. For example the enabled_accessibility_services key in the global table is not an integer.
 

fmcpma

Member
Well, that works too. I just thought that an integer would be the proper type to assign an integer system setting to, since the setting I am interested in is an integer.

Thanks.

BTW, since I now have to convert string to integer, I thought I'd have to use strval. Turns out that if I assign directly string var to integer var it works perfectly. Furthermore, if the string var contains anything like an arithmetic operation, like 3*2, and I assign it directly to the integer var, I end up with the result, 6 in this case, whereas if I use strval I end up with 0.

So, is there any use at all in strval?
 

MacroDroidDev

Administrator
Staff member
I don't remember the full historic detail, but I believe strval used to be the only way to do this, but I tried to make it easier for things to just work so I made writing strings to integers work directly.

So there probably is little use for strval nowadays but it's been around for a long time so makes no sense to remove it.
 

fmcpma

Member
Yeah, if you removed it, that would probably break quite a few macros out there…

But I'm glad conversion is automatic now.
 

余川705

New member
我不记得完整的历史细节,但我相信strval曾经是唯一的方法这样做,但我试图使它更容易的事情只是工作,所以我使写入字符串整数工作直接。

因此,现在strval可能没有什么用处,但它已经存在了很长时间,所以删除它是没有意义的。
曾经也可以直接将字符串设置为整数,先定义一个字符串变量,把他的值改成任意的整数,之后设置一个整数变量并直接选择这个字符串变量的时候是可以点击确定的
 
Top