Home   Help Search Login Register  

Author Topic: escape characters?  (Read 917 times)

0 Members and 1 Guest are viewing this topic.

AvalanCh3

  • Guest
escape characters?
« 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]

StonedSoldier

  • Guest
Re:escape characters?
« Reply #1 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]

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:escape characters?
« Reply #2 on: 14 Dec 2004, 01:47:09 »
Did that work?

What about using %%  ?

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:escape characters?
« Reply #3 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
« Last Edit: 14 Dec 2004, 01:51:09 by Triggerhappy »

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:escape characters?
« Reply #4 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.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline benreeper

  • Members
  • *
  • I'm a llama!
Re:escape characters?
« Reply #5 on: 14 Dec 2004, 04:37:58 »
format["100%1", "%"]

--Ben
« Last Edit: 14 Dec 2004, 04:39:00 by benreeper »