OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: AvalanCh3 on 13 Dec 2004, 06:24:56

Title: escape characters?
Post by: AvalanCh3 on 13 Dec 2004, 06:24:56
does anyone know how to escape a character for format?
is seems that i cannot print the % sign while using a format

hint format["%1"+"%",123]
Title: Re:escape characters?
Post by: StonedSoldier on 13 Dec 2004, 11:04:55
in most other languages you can put "\" (backslash) in front of a charater so it displayed (dunno bout OFP)

or you can do something that i always do,

_percent = "%"
hint format ["%1%2",123,_percent]
Title: Re:escape characters?
Post by: THobson on 14 Dec 2004, 01:47:09
Did that work?

What about using %%  ?
Title: Re:escape characters?
Post by: Triggerhappy on 14 Dec 2004, 01:50:34
why can't you do:
hint format["%1%",123]
maybe, or this:
hint format["%1","%2,123,%]

the problem is that % is a command in script
Title: Re:escape characters?
Post by: General Barron on 14 Dec 2004, 03:31:39
Yah, I'm pretty sure the only escape char in ofp is 'newline' (\n). I seem to remember trying to do this before, with no success...

You can always just put a space between the % and your numbers. Triggerhappy's second idea is interesting, even though it doesn't do what you want, and he messed up the quotes. :P

However, I don't know if you can use the + operator like how you are doing it, in the middle of a format command. Try this instead:

hint (format["%1",123] + "%")

Parenthesis may not be needed, but they help clarify the point. Format makes one string, and then you concatanate it with your other string "%" using the + operator.
Title: Re:escape characters?
Post by: benreeper on 14 Dec 2004, 04:37:58
format["100%1", "%"]

--Ben