SOLVED Remove " from string

Morkinas

Member
Hello, Im really lost, I still use gms 1.4 can't find info about how type/remove char from/to string ( " )

Thanks.
 
Last edited:

chamaeleon

Member
Hello, Im really lost, I still use gms 1.4 can't find info about how type/remove char from/to string ( " )

Thanks.
It is a bit unclear what you really want to so, but you can create a string with the double quote in it using 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 is a bit unclear what you really want to so, but you can create a string with the double quote in it using 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 "\").
GML:
draw_text(0, 0, "John: \"Good morning!\"");
EDIT: Doesn't work in GMS1.4, apparently
 
Last edited:
Only applicable in GMS 2, or am I wrong?
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!"+'"');
 

Evanski

Raccoon Lord
Forum Staff
Moderator
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!"+'"');
GMS2 changed the special stuff in strings / # \\
in gms 1 \\ is a new line
in gms2 \n is a new line
 

TheouAegis

Member
It used to be if you needed to use an apostophe, you wrap the string in doubles. If you needed doubles, you wrap it in apostrophes.
 

FoxyOfJungle

Kazan Games
In GMS 1.4, you can use chr(34) as chamaeleon said. Insert this in any part: "+chr(34)+"
http://www.asciitable.com/ <- Here you can find all decimal characters.
Example:

GML:
var _string = "This is a tiny text "+chr(34)+"example"+chr(34)+" to test it."


Taking the opportunity to say that it is also possible to write lines using spacings through the character "@". (GMS 2 only)
Example:

GML:
var _string =
@"Hello
World

How are you?
"
 
Last edited:
Top