Hi there,
I want to use a backslash within the text of a label. That results in a compiler error "unclosed string literal".
Do I really have to use SetText() to fill that label, for example within initialize section?
I assumed, a text label could contain any kind of text.
Roland
how to use a backslash in a textlabel
Re: how to use a backslash in a textlabel
\\ solves the compiler error, but it is show in the text label as \\.
Re: how to use a backslash in a textlabel
Strange, in my quick test in VMD \\ produces \ in a Text Label.
...
...
-
- Posts: 625
- Joined: Mon Nov 15, 2021 9:23 pm
Re: how to use a backslash in a textlabel
That's Windows behavior. Is the target platform here actually Windows?
Cyberwerks Heavy Industries -- viewforum.php?f=76
Re: how to use a backslash in a textlabel
Hi ColinP,
it's confusing. In VMD Editor double backslash is shown as "\\" but in the debugger as "\". However your hint really helps me. Thank you for quick response.
Roland
it's confusing. In VMD Editor double backslash is shown as "\\" but in the debugger as "\". However your hint really helps me. Thank you for quick response.
Roland
Re: how to use a backslash in a textlabel
I don't think it's anything specific to Windows. \ is the escape character in C strings, so its use goes back to at least 1972. It may even have been part of B, or even ALGOL which takes us back to 1958.UrbanCyborg wrote: ↑Tue Dec 14, 2021 12:33 pm That's Windows behavior. Is the target platform here actually Windows?
So \\ = \, \" = ", \n = newline, \0 = null and such like.
Java uses the same convention.
Re: how to use a backslash in a textlabel
Hi Roland,
I'm presuming that the VMD editor works as a frontend pre-processor that spits out Java from the dialog fields verbatim.
So anything you type in the text label field will simply be wrapped in "" and fed to the compiler. At least that's my guess about how it works but I'm not 100% sure.
Do you mean you are getting different results in VM proper and VMD's test client? Unfortunately they don't match in some cases, so I always consider VM proper as the benchmark testing environment as that's what end users see.
Re: how to use a backslash in a textlabel
Hi Colin,
by now I'm still working on java script for that module. I did not publish it yet.
You are right. VMD debugger works rather slowly and sometimes it shows GUI not exactly as it should do. So one need to publish an item in order to see and test in within VM.
Again and again I esteem forums like this very much because there are many helpful people like you. Thank you again.
Roland
by now I'm still working on java script for that module. I did not publish it yet.
You are right. VMD debugger works rather slowly and sometimes it shows GUI not exactly as it should do. So one need to publish an item in order to see and test in within VM.
Again and again I esteem forums like this very much because there are many helpful people like you. Thank you again.
Roland
Re: how to use a backslash in a textlabel
I double checked and as I thought the dialog field is copied verbatim into the automatically generated code in the method initializeControls()...
textLabel1 = new VoltageLabel( "textLabel1", "textLabel1", this, "test \\ test" );
textLabel1 = new VoltageLabel( "textLabel1", "textLabel1", this, "test \\ test" );