View Full Version : EXECUTE backslash issue

03-06-2012, 09:26 AM
I am having a problem getting EXECUTE to properly interpret a string with a backslash character. It wants to add an escape sequence which was previously avoided.

str = 'This is a test of system\\700 protocol.' ; This is actually a string coming from a GUI input text field via WwGetValue()
; which does not have the double-backslashes, but I have done it this way to emulate how the string is populated
print, str
; This is a test of system\700 protocol.
str2 = 'var = "' + str + '"'
print, str2
; var = "This is a test of system\700 protocol"
; Everything is fine so far
st = EXECUTE(str2)
info, var
; VAR STRING = 'This is a test of systemA protocol'
; Now the string has been corrupted

Is there any way to turn off this behavior? It occurs throughout my code, so fixing it syntactically will be time-prohibitive.

03-06-2012, 03:53 PM
Hello hcrisp,

I usually wait a day or two in responding to Forum posts in order to let other users respond, but all I can say on this one is Wow!! You couldn't have been more unlucky with this particular string even if you had tried! And it's a bit of a head-scratch-er.... Basically, what you have is a 'perfect storm' of characters that touch string processing, regular expressions, and special syntax related to octal number representation.

PV-WAVE, by the way, is doing exactly what it's supposed to do, and exactly what's documented. And no, you can't turn this off; it's part of the PV-WAVE language and there by design. And it's not an EXECUTE issue either.

The short answer is that PV-WAVE is converting this string, because of the backslash and a leading '7', into the ASCII Bell character. It's not 'corrupted'; what you're seeing is your OS trying it's best to print this unprintable ASCII Bell representation. If the number had been an 8, you wouldn't have seen this issue (8 isn't a valid value for an octal number).....

However there is a very simple solution; add a space in front of the 7. Or rearrange the content of the strings being presented in your GUI.

To fully understand what's going on and why, I refer you to these sections in the PV-WAVE documentation. Each of these areas play a role in what you're seeing with this particular string.

Programmers Guide -> Constants -> Representing Nonprintable Characters with Unix/OpenVMS - - - see the '\007' in the table.

Programmers Guide -> Using Regular Expressions -> Escaping Special Characters

Hope this helps,

Don B.