ID:2384335
 
(See the best response by Nadrew.)
Descriptive Problem Summary:Within the winset() proc, I tend to define text params by setting them within ' '. This allows text to be passed through them without the need for ASCII. However, if I need to pass an apostrophe within the text string, it closes the string early, even if preceded by \.

Numbered Steps to Reproduce Problem:
1. Create a skin window control. Name it Test.
2. Place a label pane within it and name it "Title".
3. Place the code snippet below in the Login() proc.

Code Snippet (if applicable) to Reproduce Problem:
winset(src, "Test.Title","text = 'Let\'s get started!'")


Expected Results:Ideally, the \ would permit the apostrophe to be passed without closing out the string.

Actual Results: "Let" winds up being the only text passed through for that parameter.


Workarounds:To simply write out the ASCII for every text string.

Best response
You need to double-escape in this case.

winset(src, "Test.Title","text = 'Let\\'s get started!'")
In response to Nadrew
Nadrew wrote:
You need to double-escape in this case.

> winset(src, "Test.Title","text = 'Let\\'s get started!'")
>


Ah, perfect. Thank you so much.

Alternatively, in 512 you can also use raw strings. A raw string will not respect escape characters or embedded expressions at all.

winset(src, "Test.Title",@"text = 'Let\'s get started!'")

However, in winset() you should use double quotes instead of single, as a rule. Single quotes are meant to be usable for file references and there are a few cases IIRC where they're treated differently. When in doubt, always use double quotes. And never put spaces around the = because that's incorrect syntax, and there are also some winset cases that care about that.

winset(src, "Test.Title",@#text="Let's get started!"#)


[edit]
Odd. I had updated the syntax highlighting for the site but it appears it didn't take. I'd better double-check that at some point.