Home > Software design >  Issue in Leading zero in CMD
Issue in Leading zero in CMD

Time:11-15

I am made a CMD batch file to generate the barcode numbers. Batch script generate the last ninth number of barcode by doing the calculation and generate the file named "barcode.txt". The code is working fine. Only the problem is when the "fn" number "Barcode Eight Digit " start with zero then the code is not working properly.

@echo off
setlocal EnableDelayedExpansion
set /p al=Please enter Alfa two digit:
set /p fn=Please enter Barcode Eight Digit:
set /p no=Please enter number of Barode:
set /a NUMBER=%fn%
set /a to=%no%
set /a count=1
pause
:loop
if %count% GTR %to% GOTO :end
set var1=%NUMBER:~0, 1%
set var2=%NUMBER:~1, 1%
set var3=%NUMBER:~2, 1%
set var4=%NUMBER:~3, 1%
set var5=%NUMBER:~4, 1%
set var6=%NUMBER:~5, 1%
set var7=%NUMBER:~6, 1%
set var8=%NUMBER:~7, 1%
set /A B1 = %var1% * 8  
set /A B2 = %var2% * 6
set /A B3 = %var3% * 4
set /A B4 = %var4% * 2
set /A B5 = %var5% * 3
set /A B6 = %var6% * 5
set /A B7 = %var7% * 9
set /A B8 = %var8% * 7
set /A B9 =            
  • Related