In script variable, make new line or tab?

Post your questions and help other users.

Moderator: Martin

Post Reply
angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

In script variable, make new line or tab?

Post by angelatwork » 30 Aug 2014 16:13

Is it possible to make a new line or tab in a variable that you want to show in a widget?
Best regards,
AngelAtwOrk

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

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

Post by Martin » 31 Aug 2014 15:01

You can use \n for a newline or \t for a tab:
variable = "line1\nline2";

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

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

Post by angelatwork » 01 Sep 2014 07:21

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 } "
Best regards,
AngelAtwOrk

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

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

Post by Martin » 01 Sep 2014 16:25

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.

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

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

Post by angelatwork » 01 Sep 2014 18:12

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?
Best regards,
AngelAtwOrk

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

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

Post by Martin » 01 Sep 2014 18:32

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.

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

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

Post by angelatwork » 02 Sep 2014 08:21

In what context ? How do I enable multiline in widget display,notification, input dialog(get element) or write to file?
Best regards,
AngelAtwOrk

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

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

Post by angelatwork » 02 Sep 2014 10:32

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 ;-) ).
Best regards,
AngelAtwOrk

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

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

Post by Martin » 02 Sep 2014 18:40

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?

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

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

Post by angelatwork » 03 Sep 2014 08:41

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.
Best regards,
AngelAtwOrk

Post Reply