Quotes in variables

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times

Quotes in variables

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Quotes in variables

Post by Benj »

Hello Ondra

To do this you will have to assign the ascii numeric value for the " character.

MyStringVar[70] = 34

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times

Re: Quotes in variables

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Quotes in variables

Post 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

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: Quotes in variables

Post by Steve »

You might be able to use "escape sequences" using the backslash character, like this:

Code: Select all

example_String = "\"Hello\""

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times

Re: Quotes in variables

Post by Ondra »

Thanks for going the extra on this Steve. I thought I saw something like that somewhere.

Ondra

Post Reply