- May
- 380
- 4
Hello all,
I was looking for a %@Round function but surprising (to me) it doesn't seem TCC has one. Ok, I'll write my own. Looking to round to the nearest integer.
I created a user defined function in my functions file:
The logic seems to work fine. However, I get an odd echo command. The first error in the following is expected. But I'm not sure why the 2nd produces the odd echo error.
I'm sure it's something silly, but it's got me scratching my head.
I appreciate any thoughts and I hope everyone is having a great holiday season.
Michael
BTW, it would be really great if you didn't need to write a user defined function in one line. I love the library ability to use {}. It saves all of that %+ ^ stuff to keep it all on the same line.
I was looking for a %@Round function but surprising (to me) it doesn't seem TCC has one. Ok, I'll write my own. Looking to round to the nearest integer.
I created a user defined function in my functions file:
Code:
Round = %+ ^
iff %@Left[1,%@Decimal[%1]] lt 5 then %+ ^
%@Int[%1] %+ ^
elseiff %@Left[1,%@Decimal[%1]] ge 5 then %+ ^
%@Int[%@Inc[%1]] %+ ^
endiff
The logic seems to work fine. However, I get an odd echo command. The first error in the following is expected. But I'm not sure why the 2nd produces the odd echo error.
Code:
TCC 22.00.30 x64 Windows 10 [Version 10.0.16299]
TCC Build 30 Windows 10 Build 16299
D:\Users\Michael>%@Round[4.5]
Unknown Command: 5
D:\Users\Michael>echo %@Round[4.5]
ECHO is OFF
Unknown Command: 5
D:\Users\Michael>
I'm sure it's something silly, but it's got me scratching my head.
I appreciate any thoughts and I hope everyone is having a great holiday season.
Michael
BTW, it would be really great if you didn't need to write a user defined function in one line. I love the library ability to use {}. It saves all of that %+ ^ stuff to keep it all on the same line.