Hi,
I am trying to create "an application" in Automagic with possibility to change the language of UI. So I have some text files in format:
variable_name=text string
To convert text from files into global_variables I use an action "Execute command" with command:
grep "global_variable" /patch/{value}.lang | cut -d "=" -f 2
And in field "Variable to store the standard output" I put "global_variable".
It works, but the global_variable is filled by text with new line which cause me some issues.
Instead of:
"Text string"
I get
"Text string
"
Does anyone know how to fix it or how to get strings for variables from txtfile in different way?
[Execute command] problem: new line on the end of output
Moderator: Martin
Re: [Execute command] problem: new line on the end of output
I found solution. 
Action script:
global_value = trim(global_value)

Action script:
global_value = trim(global_value)
Re: [Execute command] problem: new line on the end of output
To get text from files, we usually just action init variable text file, although that is limited to 1 MB files only. To get the string you want, probably it is much easier to use regex. findAll() is one the function I use a lot to parse those kind of text.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: [Execute command] problem: new line on the end of output
Thanks.
Works like a charm.
Works like a charm.
