Bug in function?

Jun 28, 2008
22
0
69
Vienna, Austria, Europe
Watch this:

C:\Programme\TCMD
> function currency=`%@comma[%@formatn[-70.2,%1]]`

C:\Programme\TCMD
> echo %@currency[741,31]
741,00

C:\Programme\TCMD
> echo %@comma[%@formatn[-70.2,741,31]]
741,31

How can this be?
Greetings WB
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,447
88
Albuquerque, NM
prospero.unm.edu
Watch this:

C:\Programme\TCMD
> function currency=`%@comma[%@formatn[-70.2,%1]]`

C:\Programme\TCMD
> echo %@currency[741,31]
741,00

C:\Programme\TCMD
> echo %@comma[%@formatn[-70.2,741,31]]
741,31

How can this be?
Greetings WB

In the first example, the first comma is a parameter separator. It separates the first argument to your function (741, which becomes %1) from the second (31, which becomes %2 and is duly ignored.)

In the second example, @FORMATN is expecting only two arguments. The second comma therefore can't be a parameter separator -- it's a thousands separator (and is ignored.) Your second argument is simply 74131 -- or 74,131 if you insert thousands separators.
 
Jun 28, 2008
22
0
69
Vienna, Austria, Europe
In the first example, the first comma is a parameter separator. It separates the first argument to your function (741, which becomes %1) from the second (31, which becomes %2 and is duly ignored.)

In the second example, @FORMATN is expecting only two arguments. The second comma therefore can't be a parameter separator -- it's a thousands separator (and is ignored.) Your second argument is simply 74131 -- or 74,131 if you insert thousands separators.

Sorry, but this is wrong. I have the german settings. Watch this:

C:\Programme\TCMD
> function currency=`%@comma[%@formatn[-70.2,%1]]`

C:\Programme\TCMD
> echo %@currency[13741,31]
13.741,00

C:\Programme\TCMD
> echo %@comma[%@formatn[-70.2,13741,31]]
13.741,31

The thousands separators are set correctly and the @formatn also correctly recognizes the comma. The next lines show this:

C:\Programme\TCMD
> echo %@formatn[-70.2,13741,31]
13741,31

C:\Programme\TCMD
> echo %@comma[13741,31]
13.741,31

Everything is fine -- but not as a function.
Greetings WB
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,447
88
Albuquerque, NM
prospero.unm.edu
Sorry, but this is wrong. I have the german settings. Watch this:

C:\Programme\TCMD
> function currency=`%@comma[%@formatn[-70.2,%1]]`

C:\Programme\TCMD
> echo %@currency[13741,31]
13.741,00

C:\Programme\TCMD
> echo %@comma[%@formatn[-70.2,13741,31]]
13.741,31

The thousands separators are set correctly and the @formatn also correctly recognizes the comma. The next lines show this:

C:\Programme\TCMD
> echo %@formatn[-70.2,13741,31]
13741,31

C:\Programme\TCMD
> echo %@comma[13741,31]
13.741,31

Everything is fine -- but not as a function.
Greetings WB

Okay, the comma is your decimal separator, not your thousands separator; got it. But the issue is still the same: that comma is being interpreted as a parameter separator, not as a part of the number. Try this to see what's happening:

Code:
function currency=`%%1 is %1 - %%2 is %2 - %%3 is %3`
echo %@currency[13741,31]
You don't want your function argument chopped up in this fashion, so I suggest that you use %$ instead of %1:

Code:
function currency=`%@comma[%@formatn[-70.2,%$]]`
echo %@currency[13741,31]

Note to Rex: In the help for FUNCTION, the section covering %$ and %n$ appears to have been copied verbatim from the alias documentation. Could use some editing, e.g. "the entire command line" should read "all arguments," and "after the alias names" might say "passed to the function."
 
Similar threads
Thread starter Title Forum Replies Date
Dick Johnson v28 Cosmetic Bug Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
R strange bug? Support 7
Jay Sage Bug With Flow Control and/or Command Grouping Support 2
M Server 2019 Bug with @execstr? Support 14
R bug _ypixels in BDEBUGGER Support 6
E Fixed Bug with DIR /Z displaying descriptions Support 8
E Text copy bug Support 1
x13 SETARRAY /Z bug Support 6
Gamegod ffind bug with chinese Support 2
Dick Johnson cdd - is this a bug or a feature? Support 7
P "Set" command behavior - a bug? Support 3
nikbackm TCC 20 variable expansion bug Support 6
gentzel Bug launching external commands in 20.11.43 Support 11
R Is this a bug in SETARRAY? Support 2
M Windows Installer bug? Support 4
vefatica @SCRIPT bug persists Support 4
M Little bug, big consequences .. Support 6
fishman@panix.com Once again the Can't Install bug bites... Support 2
gentzel Fixed dirs +n bug in 20.0.12 x64 Support 2
M Bug in Windows 10, when adding symbol to task bar Support 6
Alpengreis [Bug?] View (V) Prefs Error (TC 18.00.27 x64) Support 4
D WAD Minor Post Installation Bug in V18 Support 1
I Possible Bug: History /n Returns Nothing Support 3
samintz WAD Weird REN bug Support 6
Jay Sage WAD Possible Bug in Batch Parameters Support 7
G Bug? TCC 16.03.55 Console Palette Support 4
S Return of FTP copy bug in 16.02.48 Support 12
S XenForo bug Support 3
D TCMD16 Delete Toolbar Button bug Support 7
keithg1964 WAD 16.0027 Alias /rz bug Support 8
rfaquino WAD Apparently a bug when expanding environment variable %ProgramFiles(x86) Support 2
T Documentation @LINE[CON,n] @LINES[CON] not documented (bug?) Support 4
H TIMER bug Support 4
G Fixed @REREPLACE bug Support 15
G WAD PDIR @IF bug, @WORD bug Support 8
T Bug in TCMD but not in TCC Support 8
M WAD A complaint regarding a very irritating TCC installation behavior... (Bug?) Support 4
nickles Renaming bug? Support 9
nickles Redirect bug? Support 4
nickles UrlDecode() bug? Support 3
P WAD Bug in TC v 13.03 build 39 x64 Support 1
S Debug feature bug? Support 17
Roedy CDD /S bug Support 3
J TCCLE 12.11 dirhistory bug Support 1
S MOVE from FTP directory to another FTP directory - bug?? Support 2
T Bug in variable expansion Support 4
M An undocumented limitation and an associated minor bug... Support 1
M High-Precision arithmetic bug... Support 1
nickles REN bug Support 11

Similar threads