It is a bit unclear what you really want to so, but you can create a string with the double quote in it usingHello, Im really lost, I still use gms 1.4 can't find info about how type/remove char from/to string ( " )
Thanks.
chr(34)
which you can then use in whatever fashion you require (assign to a variable, append to another string, use as an argument in a function call, etc.)It's a lot easier to do if you use the escape character (back slash "\").It is a bit unclear what you really want to so, but you can create a string with the double quote in it usingchr(34)
which you can then use in whatever fashion you require (assign to a variable, append to another string, use as an argument in a function call, etc.)
draw_text(0, 0, "John: \"Good morning!\"");
Only applicable in GMS 2, or am I wrong?It's a lot easier to do if you use the escape character (back slash "\").
GML:draw_text(0, 0, "John: \"Good morning!\"");
Huh, I was pretty sure you could do it. I definitely remembered escaping newlines with backspace by doing "\#" at least. Guess it doesn't work. If that's the case, the easiest alternative without having to resort to chr()'s magic numbers would be to use single quotes as string delimiters and enclose the double quotes:Only applicable in GMS 2, or am I wrong?
draw_text(0, 0, "John: "+'"'+"Good morning!"+'"');
GMS2 changed the special stuff in strings / # \\Huh, I was pretty sure you could do it. I definitely remembered escaping newlines with backspace by doing "\#" at least. Guess it doesn't work. If that's the case, the easiest alternative without having to resort to chr()'s magic numbers would be to use single quotes as string delimiters and enclose the double quotes:
GML:draw_text(0, 0, "John: "+'"'+"Good morning!"+'"');
I know about the GMS2 changes; I just remembered wrong about being able to escape quotes in GMS1.GMS2 changed the special stuff in strings / # \\
in gms 1 \\ is a new line
in gms2 \n is a new line
I like your alternative wrapping the double quote in single quotes. Makes it easier to read than chr(34). Forgot about it as an option.I know about the GMS2 changes; I just remembered wrong about being able to escape quotes in GMS1.
var _string = "This is a tiny text "+chr(34)+"example"+chr(34)+" to test it."
var _string =
@"Hello
World
How are you?
"
Only in GMS2. This topic is tagged GMS1.4.Taking the opportunity to say that it is also possible to write lines using spacings through the character "@".
Example:
GML:_var string = @"Hello World How are you? "
This post can be useful to learn GML tricks for other people that is viewing too. (people using GMS 2.)Only in GMS2. This topic is tagged GMS1.4.