Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: HandsFree on Fri 04/07/2014 11:09:45

Title: Writing a string in multiple lines in editor
Post by: HandsFree on Fri 04/07/2014 11:09:45
Hi,

Can't find this anywhere.
Is it possible to continue a statement on a next line somehow? I have some long texts and I would like it to remain readable in the editor without scrolling.
In VB you would use &_ I think:
Code (ags) Select

sLongText = "the long text" &_
" continues here.";

Does AGS have something like this?
Title: Re: Writing a string in multiple lines in editor
Post by: Adeel on Fri 04/07/2014 14:25:42
E: Nvm. I read your post too fast. I thought you were asking for breaking line in "Display()" command.
Title: Re: Writing a string in multiple lines in editor
Post by: Monsieur OUXX on Fri 04/07/2014 15:37:04
As far as I know, it's not possible.
AGS can handle instructions being split over several lines, but not when it's inside quotes (inside of a string)

The best workaround I can think of is :

Code (ags) Select

  String s =    "Line #1";
  s = s.Append( "Line #2");
  s = s.Append( "Line #3");
  s = s.Append( "Line #4");
  s = s.Append( "Line #5");
Title: Re: Writing a string in multiple lines in editor
Post by: HandsFree on Fri 04/07/2014 17:36:45
Yes, so far I've done the thing with the appends but that feels like a strange workaround. And I read that the translation file doesn't recognize appends so another way of doing this would be welcome.

Just so I know, how does it work when not inside quotes?
Title: Re: Writing a string in multiple lines in editor
Post by: Gurok on Fri 04/07/2014 20:28:41
When it's not inside quotes, a statement only ends in AGS when you place a semicolon after it. Something like this is valid AGS script:

int
x
;
x
=
0
;
while
(
x
<
10
)
x++
;


Moreover, new lines are treated just like they're spaces. If you need to space things out, any whitespace will do :D
Title: Re: Writing a string in multiple lines in editor
Post by: Billbis on Sat 05/07/2014 07:47:18
For translations :
Code (ags) Select
if (Game.TranslationFilename =="") {
    lText = "My text 1";
    lText = lText.Append("and my text 2.");
} else if (Game.TranslationFilename == "French") {
    lText = "Mon texte 1";
    lText = lText.Append("et mon texte 2");
} else if (Game.TranslationFilename == "Spanish") {
    ...
}
labCreditText.Text = lText;
Title: Re: Writing a string in multiple lines in editor
Post by: HandsFree on Sun 06/07/2014 11:27:24
Ok thanks. :smiley:
Translation are going to be very unfun this way. :confused:
Title: Re: Writing a string in multiple lines in editor
Post by: Crimson Wizard on Sun 06/07/2014 14:18:34
Quote from: Billbis on Sat 05/07/2014 07:47:18
For translations :
Code (ags) Select
if (Game.TranslationFilename =="") {
    lText = "My text 1";
    lText = lText.Append("and my text 2.");
} else if (Game.TranslationFilename == "French") {
    lText = "Mon texte 1";
    lText = lText.Append("et mon texte 2");
} else if (Game.TranslationFilename == "Spanish") {
    ...
}
labCreditText.Text = lText;


What??
Code (ags) Select

lText = GetTranslation("My text 1");
lText = lText.Append(GetTranslation("and my text 2."));
Title: Re: Writing a string in multiple lines in editor
Post by: Billbis on Mon 07/07/2014 13:46:07
:-[
Why I haven't thank about that method earlier? Sorry about that.