Function code of batch implementation calculator (summary)

Time:2020-3-30

A small calculator made of bat / batch
This is a small calculator I made with bat / batch processing. I can use it by copying the attached code directly to Notepad and saving it in. Bat format.
Calculation formula is supported, such as input: 12 + 12 / (7-5); but only integer calculation is supported, not decimal.
It’s not very useful and the technical content is not very high, but the process control is very good. I think logic and abstract thinking are very strong, and I feel 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 use the small calculator (DCAL. Bat)% xpprogname% _v% xpprogver%
color 1f
rem mode con cols=80 lines=40
Echo welcome to use the small calculator (DCAL. Bat)% 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.
REM important statement:
REM this program is written by Tao Yongli, you can spread it freely, but please do not delete the following information!
REM for commercial use, please contact the author.
echo Version:
echo ——————————
echo Program: %xpProgName%
echo Author: Taoether
echo Version: %xpProgVer%
echo IssueTime: 09:01 2009-2-18
echo UpdateTime: 9:01 2009-6-5
echo Email: [email protected]
echo HomePage: www.taoyoyo.net
echo ——————————
echo.
echo Version Log:
echo —————————————–
echo Ver. Date. Log.
echo —————————————–
echo V1000 20090218 New program issue.
echo V1001 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, it returns the calculation result.
echo.
echo DCal [M]
echo.
Echo [M]: Specifies the mode of operation
Echo = empty, enter calculation mode
Echo = C, clear screen;
Echo = h, display help;
Echo = V, display version;
echo.
Echo Description:
echo.
Echo 1, in calculation mode:
Echo directly input the calculation formula, 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, the calculator can realize simple calculation and support the following operations in descending priority order:
echo.
Echo() – grouping
Echo * /% – arithmetic operator
Echo + — arithmetic operator
Echo ^ < ^ < ^ > ^ > – logical shift
Echo – bitwise AND
Echo ^ ^ – bitwise “different”
Echo ^| – bitwise “or”
Echo = * = / =% = + = – = – assignment
Echo ^ & = ^ = ^| = ^ < ^ < = ^ > ^ > = – binary operation assignment
Echo, – expression separator
echo.
Echo if you use any logical or redundant operators, you need to enclose the expression string in quotation marks.
Echo any non numeric string key in an expression as the name of the environment variable whose value has been converted to a number before use.
Echo if an environment variable name is specified but not defined in the current environment, the value is set to zero.
Echo this allows you to use the environment variable values for calculations without typing those% symbols to get their values.
Echo if set / A is executed on the command line outside the command script, it displays the last value of the expression.
Echo the assigned operator needs an environment variable name to the left of the assigned operator.
Echo except for hexadecimal with prefix of 0, octal with prefix of 0, the number value is decimal.
Echo therefore, 0x12 is the same as 18 and 022.
Echo please note that octal formulas can be confusing: 08 and 09 are invalid numbers 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 calculation mode: (display help: press h; display version: press V; clear screen: Press C; exit: press E)
echo.
:Calc
Set / P input = please 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 is:% 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 wish you a good job and a happy mood!
echo.

Streamlined Edition:

Copy codeThe code is as follows:
@echo off
:Calc
Set / P input = please enter the expression:
set /a result=%input%
Echo calculation result is:% input% =% result%
goto Calc

A calculator is made with batch processing. The code is as follows

Copy codeThe code is as follows:
@echo off
:xixi
set /a a=NULL
cls
set x=
Set / P x = expression:
set /a a=%x%>>nul
Echo result is:% a%
ping -n 5 127.1>nul
goto xixi

For example, input: 4587 * 45487 + 49864-1546545 * 42431355 / 54641 + 15464 + 554 * 54545 / 1213 / 564354 * 1234365
You’ll find out: 208728936
Another example: 12 / 125 + 1215 + (13241 + 12412) * 41545
The result is: 1065755100 you can use brackets. For details, see the detailed usage of set.
Copy the code and paste it in Notepad, change the suffix of Notepad to. Bat, double-click to run it directly.

Recommended Today

Configure Apache to support PHP in the Apache main configuration file httpd.conf Include custom profile in

In Apache’s main configuration file / conf/ http.conf Add at the bottom Include “D:workspace_phpapache-php.conf” The file path can be any In D: workspace_ Create under PHP file apache- php.conf file Its specific content is [html] view plain copy PHP-Module setup LoadFile “D:/xampp/php/php5ts.dll” LoadModule php5_module “D:/xampp/php/php5apache2_2.dll” <FilesMatch “.php$”> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch “.phps$”> SetHandler application/x-httpd-php-source </FilesMatch> […]