Page 1 of 1

An easy set calculation

Posted: 31 Jan 2019 02:44
by Nattugla

I am not very familiar with Batch Scripts, but I do want to learn.
I am not sure if Batch is the way to go, with what I want to archive.

I work a lot with ink.vat prices to customers, and ex.vat in orders.
I always have to use the calc.exe to calculate (Ink.vat / 1.25) to get the ex.vat.

With Batch. Could I make something that would take the Highlighted value, divide it by 1.25 and then paste/replace the value? Then maybe connect the batch file to a Hotkey.

So I could highlight the ink.vat, hotkey, and now its ex.vat.

Is Batch a good way to go here? Or PowerShell, Autoit...?

Re: An easy set calculation

Posted: 31 Jan 2019 07:39
by Squashman
The set command can only work with 32 bit Integers. It cannot do floating point math. You are better off doing this in Powershell.

Re: An easy set calculation

Posted: 31 Jan 2019 19:34
by Aacini

Code: Select all

@echo off


   set "num="
   set /P "num=Enter integer number: "
   if not defined num goto :EOF

   set /A "div=num*80"
   echo %num% / 1.25 = %div:~0,-2%.%div:~-2%

goto loop

Code: Select all

Enter integer number: 10
10 / 1.25 = 8.00
Enter integer number: 100
100 / 1.25 = 80.00
Enter integer number: 1000
1000 / 1.25 = 800.00
Enter integer number: 1234
1234 / 1.25 = 987.20
Enter integer number: 123456
123456 / 1.25 = 98764.80