|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Sep 19, 2011 2:15 am
%format with % symbols in the format string (bug?) |
%format doesn't work if there are % symbols in the format string. I've found that doubling the % works, but only if that's at the very end of the string. I haven't yet found a way of getting %s to show in the middle. Am I just missing something or is there a bug here? If it matters, this is the function I'm trying to get working:
Code: |
#FUNCTION formatLine {#RETURN %format( %concat( %ansi( cyan), "&8s : ", %ansi( grey), "&5.2n%", %ansi( cyan), " Focus On : ", %ansi( grey), "&5.2n%", %ansi( cyan), " Focus Off : ", %ansi( grey), "&5.2n%"), %1, %2, %3, %4)} |
|
|
|
|
Arde Enchanter
Joined: 09 Sep 2007 Posts: 605
|
Posted: Wed Sep 21, 2011 8:50 pm |
Move your "%" sign out from format and just %concat it as regular text.
something like
%concat(%format("&3.0n",@SomeData/100, "%)")
works fine for me
Btw, why not to move from %1, %2, %3, %4 and let your formatLine function to have 4 parameters, it's more CMUD-style. |
|
_________________ My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Sep 21, 2011 8:56 pm |
Not a bug. % is an alternative wildcard character for the format string. Perhaps this could be smartened up a bit so that any use of % or & that doesn't have a valid set of wildcard info immediately after could be handled literally, but that really depends on if Zugg is calling some external format function or not.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Sep 21, 2011 9:05 pm |
Arde: That would work fine if the % symbols were at the end of the string, but I can't %concat to the middle. And I don't understand the second part of your post...my formatLine function does take 4 parameters...
Matt: Not being able to use a % symbol in the format string may not be a bug, but I think the doubling it only working at the end may be. And bug or not, is there another way I can use % signs in %format? It's very inconvenient... |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Sep 21, 2011 9:21 pm |
You have to use &s and then include it as a value argument. For example, to format something as common as a HP percent, it'd look like so:
%format("HP: &3.0f&s",@curhp,"%") |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Arde Enchanter
Joined: 09 Sep 2007 Posts: 605
|
Posted: Wed Sep 21, 2011 9:22 pm |
What do you want to concat in the middle? In the middle of what? Broke your string into 2 parts and have the "%" at the end of a string, then %concat everything.
Why not to use %concat("abc ", %format(..), "% def") to have "abc 50% def"? I can't understand. |
|
_________________ My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Sep 21, 2011 9:35 pm |
Ah, great idea Matt, thanks!
Arde - which code do you think is better?
Code: |
#FUNCTION formatLine {#RETURN %format( %concat( %ansi( cyan), "&8s : ", %ansi( grey), "&5.2n%", %ansi( cyan), " Focus On : ", %ansi( grey), "&5.2n%", %ansi( cyan), " Focus Off : ", %ansi( grey), "&5.2n%"), %1, %2, %3, %4)} |
Code: |
#FUNCTION formatLine {#RETURN %concat( %ansi( cyan), %format( "&8s", %1), " : ", %ansi( grey), %format( "&5.2n", %2), "%", %ansi( cyan), " Focus On : ", %ansi( grey), %format( "&5.2n", %3), "%", %ansi( cyan), " Focus Off : ", %ansi( grey), %format( "&5.2n", %4), "%")} |
|
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Sep 21, 2011 9:38 pm |
BTW, since you said % is the same thing as & in the format string, I tested this with &. The same bug exists - doubling it only works if it's at the end of the string. Oddly, when you do double it, it changes into a %...
|
|
|
|
Arde Enchanter
Joined: 09 Sep 2007 Posts: 605
|
Posted: Thu Sep 22, 2011 5:31 am |
Daern wrote: |
Arde - which code do you think is better? |
I do not think, I'm absolutely sure. The second one is better.
This one is even better than your second one:
Code: |
#FUNCTION formatLine {#RETURN %concat("<color cyan>", %format("&8s", %1), " : </color><color grey>", %format("&5.2n", %2), "%</color><color cyan>, " Focus On : </color><color grey>, %format("&5.2n", %3), "%</color><color cyan>, " Focus Off : </color><color grey>, %format("&5.2n", %4), "%</color>")} |
|
|
_________________ My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Thu Sep 22, 2011 3:02 pm |
Right, four calls to %format is definitely way more efficient than one...
Anyway, sarcasm aside, there's a bug here. I'm just reporting it, there's no need for arguments. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|