• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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?
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
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