Aptitude (12) C (2) C++ (10) CSS (1) Data Structure (2) English (7) General (14) HTML (3) Integration (1) Itinerary and Travel Cost (1) Java (29) JQ (5) JS (5) JSP (1) Lightning (14) logical (3) Math (1) Music Notation (17) MySql (4) Network (1) Regex (1) salesforce (131) Servlet (4) SF Admin (31) SF Dev (102) SQL (4) SQL_SERVER (1) StudyPoints (2) ytChannels (2) अन्ताक्षरी (4)

DOS Programming

@echo off
rem demo all arithmetic operator

rem set /p is used for prompt reading on variable
set /p val1="Enter first value :"
set /p val2="Enter second value :"

echo ********* arithmetic operator demo ************
rem set /a is used for arithmetic calculation
set /a res=%val1%+%val2%
echo Sum of %val1% and %val2% is %res%

set /a res=%val1%-%val2%
echo Subtraction of %val1% and %val2% is %res%

set /a res=%val1%*%val2%
echo Multiplication of %val1% and %val2% is %res%

set /a res=%val1%/%val2%
echo Division of %val1% and %val2% is %res%

set /a res=%val1%%%val2%
echo Modulo division of %val1% and %val2% is %res%

echo ********* relational operator demo @@ geq,gtr,equ,lss,leq @@************
if %val1% gtr %val2% (
echo %val1% is greater than %val2%
) else (
if %val1% lss 10 (
echo %val1% is even less than 10
) else (
echo %val1% is less than %val2%
)
)

=======================================================

@echo off
rem check for leap year using if else
set /p yval= "Enter year value :"
set /a res=%yval%%%4
if %res%==0 (
echo "%yval% is a leap year"
) else (
echo "%yval% is not a leap year"
)

rem check if file is available or not
set filename=savecustomer1.sql
if exist %filename% (
echo File exist
) else (
echo File does not exist
)

rem check exit status of last running command
DEL test.txt
if %ERRORLEVEL%==1 (
echo last operation was successful
) else (
echo problem in last operation
)

===========================================================

@echo off
echo *****Simple numeric for loop*****
FOR /L %%G IN (2,1,5) DO echo %%G

echo *****for loop working on collection*****
FOR %%G IN (Sun Mon Tue Wed Thur Fri Sat) DO echo %%G

echo *****for loop /R reading files of current directory recursively *****
For /R %%G in (*.*) do Echo "%%G"

echo ***** looping file contents @@@ Reading comma separated file @@@@******

FOR /F "tokens=1,2,3 delims=," %%G IN (persondata.txt) DO @echo %%G %%H %%I

==============================================================


No comments: