Page 1 of 1
Quotes in variables
Posted: Tue Mar 25, 2008 3:22 am
by Ondra
Good day. I would like to know how do I include quotes in a text sting when I'm trying to save the text to a variable. example:-
MyStringVar[70]= "I said "That the string component won't accept a statement with quotes in it.""
Ondra
Re: Quotes in variables
Posted: Tue Mar 25, 2008 10:13 am
by Benj
Hello Ondra
To do this you will have to assign the ascii numeric value for the " character.
MyStringVar[70] = 34
Re: Quotes in variables
Posted: Tue Mar 25, 2008 2:23 pm
by Ondra
Using the example above, are you saying that I can place 34 in place of the quotes an it will print out as ".
So then this : - MyStringVar[70] = "I said 34 That the string component won't accept a statement with quotes in it.34"
would print out as this :- I said "That the string component won't accept a statement with quotes in it."
Ondra
Re: Quotes in variables
Posted: Tue Mar 25, 2008 4:07 pm
by Benj
Hello Ondra
No you cannot include the number 34 inside the speechmarks or it will be interpreted as the ascii chars for 3 and 4. You must do the following to assign the value to a string.
example_String = " Hello "
example_String[0] = 34
example_String[6] = 34
would provide the string "Hello"
If you are wishing to send the quote characters over the RS232 then its probably easier to use 3 send macros.
Eg
RS232_Send 34
RS232_Send "Hello" or example_String
RS232_Send 34
Re: Quotes in variables
Posted: Wed Mar 26, 2008 10:35 am
by Steve
You might be able to use "escape sequences" using the backslash character, like this:
Re: Quotes in variables
Posted: Fri Mar 28, 2008 1:08 pm
by Ondra
Thanks for going the extra on this Steve. I thought I saw something like that somewhere.
Ondra