Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: strazer on Sun 11/04/2004 20:09:42

Title: How to use the [ character in strings? (SOLVED)
Post by: strazer on Sun 11/04/2004 20:09:42
The character [ is normally used to indicate a line break in strings, e.g. "Here comes [ a line break".

But how do I mask the character so it is displayed in dialogs/messages?

\[ doesn't work, nor does \\[ or /[

Edit:

AGS v2.7 Beta 11:
Quote* Added \[ to Display/Say/etc, to enable you to display the [ character rather than it doing a line break.
Title: Re:How to use the [ character in strings?
Post by: ElectricMonk on Sun 11/04/2004 20:13:38
I don't have an answer, but a related question:
How do I display " in a string?
Title: Re:How to use the [ character in strings?
Post by: strazer on Sun 11/04/2004 20:16:49
Display("These are called \"quotemarks\" ");

Check this page (http://americangirlscouts.org/agswiki/index.php/Category:Tidbits_and_Snippets) for more.
Title: Re:How to use the [ character in strings?
Post by: ElectricMonk on Sun 11/04/2004 20:55:09
Thanks... I must have glanced over the "tidbits & snippets" thread about six times by now, but somehow this bit of info never stuck...
Title: Re:How to use the [ character in strings?
Post by: Scorpiorus on Mon 12/04/2004 08:59:58
QuoteThe character [ is normally used to indicate a line break in strings, e.g. "Here comes [ a line break".

But how do I mask the character so it is displayed in dialogs/messages?
I remember it was a problem for me too when I try to create my own font which actually used that character. I had to replace it with another one. I'm not sure if it's at all possible to display it somehow. I wish AGS broke a line with '\n' :P

Title: Re:How to use the [ character in strings?
Post by: SSH on Thu 15/04/2004 13:23:51
How about Display("Here comes %s a line break", "[");
Does that work? (too lazy to try it, sorry!)
Title: Re:How to use the [ character in strings?
Post by: ElectricMonk on Thu 15/04/2004 13:36:22
Nope. The result looks something like

------------------
Here comes
 a line break
------------------

Title: Re:How to use the [ character in strings?
Post by: Pumaman on Thu 15/04/2004 21:52:39
Hmm, good question. I'm not actually sure that it's possible; and it's not a trivial matter to add some sort of  \[  support, because it's the engine's interpretation of the character, not the script compiler, that has the problem.

I suppose adding a special sequence like  %[  could represent the real thing, but that seems to be getting rather messy. Hmm.
Title: Re: How to use the [ character in strings?
Post by: strazer on Thu 06/01/2005 19:22:20
Sorry to bring this up again, but would it be possible to reserve some obscure extended character instead? Since it won't have to be displayed anyway, there should be no problems with SCI fonts.
Just a thought.
Title: Re: How to use the [ character in strings?
Post by: Pumaman on Thu 06/01/2005 20:18:00
Well, I don't want to change the character from [ at this stage, but adding some sort of escape sequence to print a real [ is a possibility.

I suppose %[ would probably do the trick, unless there are any objections?
Title: Re: How to use the [ character in strings?
Post by: Goot on Fri 07/01/2005 06:02:58
The default message for clicking on that question mark icon had a message with a break in it which used [[. That has worked for me, but maybe it doesn't in the new version.
Title: Re: How to use the [ character in strings?
Post by: Pod on Fri 07/01/2005 13:17:50
Quote from: Pumaman on Thu 06/01/2005 20:18:00
Well, I don't want to change the character from [ at this stage, but adding some sort of escape sequence to print a real [ is a possibility.

I suppose %[ would probably do the trick, unless there are any objections?

Why not /[ ? Like /"
Title: Re: How to use the [ character in strings?
Post by: TerranRich on Fri 07/01/2005 13:43:57
I believe that would be a better idea. If anybody ever wanted to end a line with a forward-slash, they could simply use "/ [" with the space in between.
Title: Re: How to use the [ character in strings?
Post by: SSH on Fri 07/01/2005 14:44:14
Quote from: Pod on Fri 07/01/2005 13:17:50
Quote from: Pumaman on Thu 06/01/2005 20:18:00
Well, I don't want to change the character from [ at this stage, but adding some sort of escape sequence to print a real [ is a possibility.

I suppose %[ would probably do the trick, unless there are any objections?

Why not /[ ? Like /"

If you're going to use a slash for an escape character, please use a backslash, like perl, csh, tcl, lisp, regexps, C, etc.
Title: Re: How to use the [ character in strings?
Post by: Radiant on Fri 07/01/2005 16:16:41
Alternatively, use one of the obscure characters such as ~ and edit the font to change its appearance to a [
Title: Re: How to use the [ character in strings?
Post by: Pumaman on Fri 07/01/2005 19:57:11
Ok, I'll add \[ to the next beta.