- Aug

- 258

- 4

I want to format a csv report to a human-readable style.

The report contains fields for nas-volumes, eg. volume size.

The size field is notated in KB and I want to replace it with MB, GB, TB if reasonable.

So in the first step I want to create a function which should return a numeric value divided by 1024 if reasonalble. But it doesn't work as expected. Have a look at this:

Code:

```
C:\Temp >function tomega=%%@if[ %%@eval[ %%1 mod 1024 ] eq 0,%%@eval[%%1/1024] (true),%%1 (false)]
C:\Temp >function
tomega=%@if[ %@eval[ %1 mod 1024 ] eq 0,%@eval[%1/1024] (true),%1 (false)]
C:\Temp >set val=16384
C:\Temp >echo %@tomega[%val]
16 (true)
C:\Temp >set val=123456
C:\Temp >echo %@tomega[%val]
5625 (true),123456 (false) <- unexpected
rem with back quotes *************************
C:\Temp >function tomega=`%@if[ %@eval[ %1 mod 1024 ] eq 0,%@eval[%1/1024] (true),%1 (false)]`
C:\Temp >function
tomega=%@if[ %@eval[ %1 mod 1024 ] eq 0,%@eval[%1/1024] (true),%1 (false)]
C:\Temp >set val=16384
C:\Temp >echo %@tomega[%val]
16 (true)
C:\Temp >set val=123456
C:\Temp >echo %@tomega[%val]
5625 (true),123456 (false) <- unexpected
```

Why are both values true/false evaluated and given back?

regards

Frank