A small calculator using bat/batch processing
This is a small calculator that I made with bat/batch processing. Copy the following code to notepad and save it as. bat format.
The formula is supported. For example, the input value is 12 + 12/(7-5), but only integer calculation is supported, and decimal calculation is not supported.
It is not very useful, and the technical content is not very high, but the process control is quite good. I think that logic and abstract thinking are still very strong, and I am also shamelessly narcissistic ~~
As follows:
Copy codeThe Code is as follows: @ echo off
Cls
: System Parameter
Set xpProgName = DosCalculator
Set xpProgVer = 1.0.0.1
Echo.
Title welcome to the small calculator (DCal. bat) prepared by Taoether % xpProgName % _ V % xpProgVer %
Color 1f
Rem mode con cols = 80 lines = 40
Echo welcome to the small calculator (DCal. bat) prepared by Taoether % xpProgName % _ V % xpProgVer %
If/I {% 1 }={} goto Main
If/I "% 1" = "C" goto Main
If/I "% 1" = "H" goto help
If/I "% 1" = "V" goto ver
: Ver
Echo.
Important rem statement:
Rem this program is compiled by Tao Yongli. You can spread it at will, but do not delete the following information!
For commercial purposes, contact the author.
Echo Version:
Echo ------------------------------
Echo Program: % xpProgName %
Echo Author: Taoether
Echo Version: % xpProgVer %
Echo IssueTime:
Echo UpdateTime:
Echo Email: taoether@gmail.com
Echo HomePage: www.taoyoyo.net
Echo ------------------------------
Echo.
Echo Version Log:
Echo -----------------------------------------
Echo Ver. Date. Log.
Echo -----------------------------------------
Echo V1000 20090218 New program issue.
Echo v100 1 20090605 Add new function: Clear.
Echo...
Echo -----------------------------------------
If/I {% 1 }={} goto Main
If/I "% 1" = "H" goto end
If/I "% 1" = "V" goto end
: Help
Echo.
Echo Help:
Echo -----------------------------------------
Echo this program is a calculator. after entering the calculation expression, return the calculation result.
Echo.
Echo DCal [M]
Echo.
Echo [M]: Specifies the running mode.
Echo = NULL. Enter computing mode
Echo = C, clear screen;
Echo = H, show help;
Echo = V. The version is displayed;
Echo.
Echo description:
Echo.
Echo 1 in computing mode:
Echo directly enters the formula, and press enter to return the calculation result;
Echo press E to exit the program;
Echo press H to display help;
Echo press V to display the version;
Echo.
Echo 2: This calculator can implement simple calculation and support the following operations in descending priority order:
Echo.
Echo ()-group
Echo */%-Arithmetic Operator
Echo +-Arithmetic Operator
Echo ^ <^>-logical shift
Echo-bitwise "and"
Echo ^-bitwise "exception"
Echo ^ |-bitwise "or"
Echo = * =/= % = + =-value assignment
Echo ^ & = ^ | = ^ <= ^> =-binary operation value assignment
Echo,-expression Separator
Echo.
Echo if you use any logical or remainder operators, You need to enclose the expression string in quotation marks.
Echo uses any non-numeric string key in the expression as the environment variable name. The values of these environment variable names are converted to numbers before they are used.
If an environment variable name is specified but not defined in the current environment, the echo value is set to zero.
Echo so that you can use the environment variable values for calculation without entering those % symbols to get their values.
Echo if SET/A is executed by A command line outside the command script, it displays the last value of this expression.
Echo the assigned operator requires an environment variable name on the left of the assigned operator.
Echo has a prefix of 0x in the hexadecimal notation, a zero prefix in the octal notation, and a decimal number.
Therefore, 0x12 is the same as 18 and 022.
Echo please note that the octal formula may be confusing: 08 and 09 are invalid digits, because 8 and 9 are not valid octal digits.
Echo -----------------------------------------
If/I {% 1 }={} goto Main
If/I "% 1" = "H" goto end
If/I "% 1" = "V" goto end
: Main
Echo.
Echo enters the computing mode: (display help: Press H; display version: Press V; clear screen: Press C; Exit: Press E)
Echo.
: Calc
Set/p input = enter the expression:
If/I "% input %" = "E" goto end
If/I "% input %" = "H" goto help
If/I "% input %" = "V" goto Ver
If/I "% input %" = "C" goto Clear
Set/a result = % input %
Echo Calculation result: % input % = % result %
Echo.
Goto Calc
: Clear
Cls
If/I {% 1 }={} goto Main
If/I "% 1" = "H" goto end
If/I "% 1" = "V" goto end
: End
Echo.
Echo wishes you a good job and a pleasant mood!
Echo.
Lite version:Copy codeThe Code is as follows: @ echo off
: Calc
Set/p input = enter the expression:
Set/a result = % input %
Echo Calculation result: % input % = % result %
Goto Calc
The Code is as follows:Copy codeThe Code is as follows: @ echo off
: Xixi
Set/a = NULL
Cls
Set x =
Set/p x = formula:
Set/a = % x %> nul
Echo result: % a %
Ping-n 5 127.1> nul
Goto xixi
For example, input: 4587*45487 + 49864-1546545*42431355/54641 + 15464*554/54545/1213*564354
The result is 208728936.
For example: 12/125 + 1215 + (13241 + 12412) * 41545
The result is: 1065755100 you can use parentheses. For details, you can see the detailed usage of set.
Copy and paste the code in the notepad, and change the suffix of the notepad to. BAT and double-click it to run it directly.