Jump to content


Photo

Text going to new line when a # is in the string


  • Please log in to reply
4 replies to this topic

#1 MetroidMan347

MetroidMan347

    GMC Member

  • GMC Member
  • 823 posts
  • Version:GM:Studio

Posted 07 April 2012 - 05:27 PM

Dear GMC,

I am making a little app to aid in the creation of scripts. As some of you probably know, a .gml script file begins with "#define Script". Therefore when that text is read (to display the file you're creating from inside game maker) it skips a line and begins printing the text a line below. Is there any possible way to fix this issue? Any and all help is appreciated! Thank You!

M
  • 0

#2 Noele

Noele

    GMC Mentor

  • GMC Member
  • 2347 posts
  • Version:GM8.1

Posted 07 April 2012 - 05:34 PM

You can use \ as a prefix to escape the next character:
E.G.
txt = "This is line #1";
outputs
This is line
1

Whareas:
txt = "This is line \#1";
Outputs
This is line 1;

You can also replace all occurrences of a substring within a string:
new_str = string_replace_all("#",old_str);
  • 1

#3 MetroidMan347

MetroidMan347

    GMC Member

  • GMC Member
  • 823 posts
  • Version:GM:Studio

Posted 07 April 2012 - 05:36 PM

You can use \ as a prefix to escape the next character:
E.G.
txt = "This is line #1";
outputs
This is line
1

Whareas:
txt = "This is line \#1";
Outputs
This is line 1;

You can also replace all occurrences of a substring within a string:
new_str = string_replace_all("#",old_str);


So I can simply modify the text that is drawn and leave the file unchanged?
EDIT: Okay yeah I see. Thanks man, +1-ed.

Edited by MetroidMan347, 07 April 2012 - 05:37 PM.

  • 0

#4 TerraFriedSheep

TerraFriedSheep

    GMC Member

  • GMC Member
  • 2821 posts
  • Version:GM:Studio

Posted 07 April 2012 - 05:50 PM

You can also replace all occurrences of a substring within a string:
new_str = string_replace_all("#",old_str);


You missed an argument, and mixed up the order in the quoted function; it should be:

new_str = string_replace_all(old_str,"#","");

  • 0

#5 MetroidMan347

MetroidMan347

    GMC Member

  • GMC Member
  • 823 posts
  • Version:GM:Studio

Posted 07 April 2012 - 07:46 PM

You can also replace all occurrences of a substring within a string:
new_str = string_replace_all("#",old_str);


You missed an argument, and mixed up the order in the quoted function; it should be:

new_str = string_replace_all(old_str,"#","");

Don't worry, I fixed it before I used it.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users