• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[vJASS] String "%" and "|"

Status
Not open for further replies.
Level 7
Joined
Apr 30, 2011
Messages
359
there's something wrong with percent (%) . . .
and a little wrong for "|" . . .

i tried to do something like this:
JASS:
local string s = "!@#$%^&*()|"
call BJDebugMsg(SubString(s, udg_int, udg_int + 1))

//  if udg_int = 4
//  the result should show a "%"
//  but it doesn't, it shows the next character instead (^)

//  if udg_int = 10
//  the result shows a "|"
//  but i tried that for many characters at once,
//  and it turned out to be . . .
//  1. first "|" will be shown just normally
//  2. next "|" will be hidden
//  3. next "|" will be shown
//  4. next "|" will be hidden
//  5. . . . . .

for percent (%), it can be fixed by typing the percent twice (%%)
"%%" = "%"
for "|", can't be fixed, but can be evaded by typing "|" twice (||)
// to avoid some bugs of "|" (only for game message i guess)
/* change */ "|" /* to */ "||"
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
% is a placeholder for variables and the following letter indicates the format.

call DisplayTimedTextFromPlayer(Player(2), 0., 0., 10., "%s")

This will write the third player's name (as string) because the function sets this variable for the passed string.

| is for color codes, although there are only |c and |r.
 
Level 7
Joined
Apr 30, 2011
Messages
359
well . . .
it's strange . . . . . .
but i think this is really happened to me :(
(at least to me only)

and how about that "|" prob?
it's right, isn't it?
 
Use ||

| is a special escape character by blizzard, so | escapes | just like \ escapes \.

\\ = \
|| = |

You can't use the two types of escape characters together, well you can ;o.
|\\ will work I believe (same idea as a\\)
\| will not work

| is sort of a pseudo escape character in that it only escapes characters that can be escaped... annoying as hell ;o.

For example, |f should display |f =).
 
Status
Not open for further replies.
Top