the scape char \n doesn't work
|
|
Azul Wilder
Registered User
Join date: 29 Jan 2007
Posts: 87
|
04-10-2007 03:12
Hi everybody!
I have a script that reads a note in the inventory. The note has texts for a hover text (llSetText), if i include the \n scape character to break the line in the text of the note it doesn't break the line in the hover text, but it appears as part of the hover text.
Does someone know how to break the lines in this case?
Thanks a lot.
_____________________
First goes before AW Devices
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-10-2007 03:28
From: Azul Wilder Hi everybody!
I have a script that reads a note in the inventory. The note has texts for a hover text (llSetText), if i include the \n scape character to break the line in the text of the note it doesn't break the line in the hover text, but it appears as part of the hover text.
Does someone know how to break the lines in this case?
Thanks a lot. When being read from the notecard the text will be literal not as an escape character. You could try using \\n in the notecard but failing that you will need to manually translate it when you read the notecard.
|
|
Azul Wilder
Registered User
Join date: 29 Jan 2007
Posts: 87
|
04-10-2007 03:33
I tried it and it fails too.
Any other suggestions?
Thanks.
_____________________
First goes before AW Devices
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-10-2007 03:36
From: Azul Wilder I tried it and it fails too.
Any other suggestions?
Thanks. yep my second line in my post, translation manually within the notecard reader
|
|
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
|
04-10-2007 10:18
Use a different line break character, like pipe | or tilde ~. Something that will never normally appear in your displayed text. Notecards use newline characters as delimiters for, well, lines. As such, you can't use them as delimiters. Solution: Use Something Else. 
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
04-10-2007 11:04
From: Newgate Ludd yep my second line in my post, translation manually within the notecard reader Which might look something like: string Line; // The line of text being evaluated integer n = llSubStringIndex( Line, "\\n" ); // index of newlines found
while( n != -1 ) { Line = llInsertString( llDeleteSubString( Line, n, n + 1 ), n, "\n" ); n = llSubStringIndex( Line, "\\n" ); }
It's times like this that an llReplaceSubString( string src, string rep, integer start, integer end )function would be really handy. I know, we can write a user function, but that entails repetitive copying of the strings in question, string = ( string = "" ) + string gag notwithstanding.
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
04-10-2007 11:22
This also works: Use %0A in the notecard where you want there to be a newline. I.e. Hello%0Athere.
Then after reading the notecard (assume it is in the 'data' string): llOwnerSay(llUnescapeURL(data));
And it will print a newline between Hello and there. This approach (though cumbersome) also works for expressing international characters and such to be read and printed from notecards. Rj
|
|
Twisted Pharaoh
if ("hello") {"hey hey";}
Join date: 24 Mar 2007
Posts: 315
|
04-10-2007 11:22
The confusion comes because on the notecard "\n" is made of 2 characters and in LSL it is just one. So you will need to escape it "\\n" so LSL will treat it as a 2 characters string.
You can then use llParseString 2List() to get the different lines. As others said I would recommend using another character for line separation, "|" is commonly used in database formats and would ease your problems.
Anyway once you have done that just use llDumpList2String(), this time with "\n" as separator that should solve your problem.
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
04-10-2007 11:24
I offer... string myString = llDumpList2String(llParseStringKeepNulls(myString, ["\\n"], []), "\n"); ...to convert \n to \\n in a string
|
|
Azul Wilder
Registered User
Join date: 29 Jan 2007
Posts: 87
|
04-10-2007 13:11
Thank you all
I'll try the different solutions and for sure my problem is solved now.
_____________________
First goes before AW Devices
|