{ in string
Moderator: Martin
{ in string
How can I include a { char in a Widget text element without it being considered the start of a string inline expression?
Re: { in string
Hi,
A widget text element should not do anything with a single opening curly brace, it just gets more complicated when an opening and closing brace are used in the text.
When you have an opening and closing curly brace, you can use following syntax when you want to avoid that Automagic replaces variables in a text like {text}:
{'{text}'}
Regards,
Martin
A widget text element should not do anything with a single opening curly brace, it just gets more complicated when an opening and closing brace are used in the text.
When you have an opening and closing curly brace, you can use following syntax when you want to avoid that Automagic replaces variables in a text like {text}:
{'{text}'}
Regards,
Martin
Re: { in string
Hello Martin,
In one of my flow I tried to execute root command:
dumpsys batterystats | grep -m1 'Screen on:' | awk -F: '{print $2}' | awk -F" " '{print $1,$2}'
but here AM also had problem with { sign and tried to interprets {print as some unknown variable
For now I am using other command, but it would be nice to know how to use this sign if it is possible
In one of my flow I tried to execute root command:
dumpsys batterystats | grep -m1 'Screen on:' | awk -F: '{print $2}' | awk -F" " '{print $1,$2}'
but here AM also had problem with { sign and tried to interprets {print as some unknown variable
For now I am using other command, but it would be nice to know how to use this sign if it is possible
Regards, piskor
Re: { in string
Hi,
You can use the same procedure to escape the curly braces.
Variant 1 (entire command enclosed in {'...'}, single quotes escaped with a backslash):
{'dumpsys batterystats | grep -m1 \'Screen on:\' | awk -F: \'{print $2}\' | awk -F" " \'{print $1,$2}\''}
Variant 2 (each 'variable' escaped on it's own within {'...'}):
dumpsys batterystats | grep -m1 'Screen on:' | awk -F: '{'{print $2}'}' | awk -F" " '{'{print $1,$2}'}'
Regards,
Martin
You can use the same procedure to escape the curly braces.
Variant 1 (entire command enclosed in {'...'}, single quotes escaped with a backslash):
{'dumpsys batterystats | grep -m1 \'Screen on:\' | awk -F: \'{print $2}\' | awk -F" " \'{print $1,$2}\''}
Variant 2 (each 'variable' escaped on it's own within {'...'}):
dumpsys batterystats | grep -m1 'Screen on:' | awk -F: '{'{print $2}'}' | awk -F" " '{'{print $1,$2}'}'
Regards,
Martin