Page 1 of 1

[Solved] String Variable Unescape function bug

PostPosted: Sun Jun 10, 2018 1:45 pm
by clyne
Hello,
I am working with escape-ed strings, and there seems to be an issue with parsing new lines (although I haven't tested with other escaped characters).
A colleague has also been able to reproduce this issue.

Code: Select all
var text="Foo\nFoo\nBar\nFoo\nBar"
//tested with '\r\n' and '\n'
Label1.Text = text.Unescape

Produces the correct result of:
Foo
Foo
Bar
Foo
Bar


Code: Select all
var text="FooBar\nFoo\nBar\nFoo\nBar"
Label1.Text = text.Unescape

produces the incorrect result of:
FooBar
Foo Bar
Foo Bar


Through further testing, it seems like the length of text before the first escaped character must be longer than any further text between escaped characters.

WD 6.0.4 Free
W10 Pro v1709 build 16299.248

Re: String Variable Unescape function bug

PostPosted: Tue Jun 12, 2018 10:10 am
by Thomas Mrozek
Hi clyne,

thank you for reporting this. I forward this to our development.

As a workaround please avoid using the "unescape" member.

E.g.
Code: Select all
WDLabelText(1,text)


cheers
Thomas

Re: String Variable Unescape function bug

PostPosted: Tue Jun 12, 2018 1:45 pm
by Thomas Mrozek
Hi,

I have to correct myself.

The "unescape" member is working correctly. The issue is the usage of "\n" and the WD label. The Label widget is developed for 1 line texts. When the label widget is in auto resize mode the 1st entry is defining the size of the label and all following lines will use this size, "\n" will just produce a space. You will see that everything is just 1 line if you turn off auto resize mode and drag the label size long.
You can cheat the new line by using "<br>", but this can raise different issues, depending on what you want to do.
Maybe a "read-only" textbox can be an alternative?

cheers
Thomas

Re: String Variable Unescape function bug

PostPosted: Tue Jun 12, 2018 2:24 pm
by clyne
Hello,

Good to know!
The end result for the unescaped string will be a text asset in PB.
The label was just a useful way to debug & test the other end of the TCP connection.

The Text Box does exactly what I need! Thanks