Page 1 of 1

In script variable, make new line or tab?

Posted: 30 Aug 2014 16:13
by angelatwork
Is it possible to make a new line or tab in a variable that you want to show in a widget?

Re: In script variable, make new line or tab?

Posted: 31 Aug 2014 15:01
by Martin
You can use \n for a newline or \t for a tab:
variable = "line1\nline2";

Re: In script variable, make new line or tab?

Posted: 01 Sep 2014 07:21
by angelatwork
Thank you, but I cannot make it work. I am doing something wrong. Before writing I had tried with "//n" or /n or "/n" or //n. Outside our even inside a variable.

Could you please, please show me how to insert a tab or a new line anywhere in the following script as an example
Script:
global_senasteRestid = "{global_rBilstart,dateformat, d/M HH:mm}" + "- "+"{global_rBilstopp, dateformat, HH:mm }"+" "+" {v_googledur, dateformat,timezone, UTC, HH:mm} "+" "+"{v_googledist} "+" m"{global_origin, locationformat, multiline}/t{global_dest, locationformat, multiline } "

Re: In script variable, make new line or tab?

Posted: 01 Sep 2014 16:25
by Martin
Did you try to use a backslash instead of a slash like this \n but not /n?
The option Multiline of the text element also has to be checked otherwise the line break will look like a regular space character.

Re: In script variable, make new line or tab?

Posted: 01 Sep 2014 18:12
by angelatwork
OMG, I must have been very tired,when i tried to figure this out :-). I looked at my old scripts and in the help section, but did not see that i again and again turned the backslash to a slash whilst trying.

The tab function does not work with multiline, is that correct?

Re: In script variable, make new line or tab?

Posted: 01 Sep 2014 18:32
by Martin
Tab works better when multiline is enabled since another text layout algorithm is used. When multiline is turned off, a tab character looks more or less like a regular space character.

Re: In script variable, make new line or tab?

Posted: 02 Sep 2014 08:21
by angelatwork
In what context ? How do I enable multiline in widget display,notification, input dialog(get element) or write to file?

Re: In script variable, make new line or tab?

Posted: 02 Sep 2014 10:32
by angelatwork
Cannot make \t (tab) work, at least not in a message dialog. \n (new line) works fine. tab does not even insert a space (when I try, best to add ;-) ).

Re: In script variable, make new line or tab?

Posted: 02 Sep 2014 18:40
by Martin
I assumed that you are talking solely about text elements on a custom widget. There's a check box Multiline directly under the text field in a custom widget to switch on the multiline mode.

It highly depends if a regular action supports multiple lines or not. Action Write to File for example should allow to press enter on most keyboards to write multiple lines to a file at a time.

Tab works for me in a message dialog, but it's also displayed as a single space for me.
I tested it using following message in an action Message Dialog: a{"\t"}b
Is there no space between the two characters on your device?

Re: In script variable, make new line or tab?

Posted: 03 Sep 2014 08:41
by angelatwork
ok, i think i tried \t where it cannot be used :-). In combination with location,locationformat,multiline. If. used there it will not insert a space.