Tuesday 15 June 2010

calculator - Batch- do more advanced calculations -


In batch, I'm having trouble computing more advanced than set / a decimal work Will not; For example set / a 5/2 instead of 2 instead of 2 . Apart from this, the batch can not compute large. Is there any way to make a temporary file (such as VBS) to make or calculate other programs (like calculator) and return to the batch file?

An example of the following batch-jscript hybrid script that allows to evaluate any JScript expression Is:

  @if (@codesection == @ batch) @then @echo off rem define a helper variable that JScript set JScall = Cscript // nologo // E: JScript "% For the ~ F0 "/ F %% ('Call in% JScall% Math' .pi ') PI = %% P / F% P recognize the internal value of ('% JScall% 4 * Math.atan (1 ^) ') For PI = %% P / F%% S ('% JScall% Math.s qrt (2 ^) ') Doko Square Root 2 = %% S / F %% t ('% JScall% 1/3 ') a set tier = %% t a third =% third in a % for / F %% o ( '% JScall %% oneThird% * 3') Repeat a third time 3 = %% o goto: EOF @end // JScript section WScript.Echo (eval (WScript.Arguments.Unnamed. Item (0))); PI = 3.14159265358979 intrinsic value = 3.14159265358979 2 = square root = 1.4142135623731 a third = 0.333333333333333 a third time 3 = 0.999999999999999   

You can review available jscript arithmetic functions:

allows to keep the BAT file Jesteepi code in this method is simple and fast. VBScript code.

No comments:

Post a Comment