batch code broken?

PGspy18

Beta member
Messages
2
Location
US
I program in batch code, so that's first things first. im writing a program and a sub-program calculates GPA, the script to write values to files is not working. can you help me?
the code is:
@echo off
setlocal enabledelayedexpansion
set l=n
set it=0
set n=0
set an=1
color 0c
if %1 NEQ show exit /b
set name=%2
title GPA Calculator - %name%
if exist Data\G\%name%\ goto load
:ret
echo %n%
pause
cls
echo Please enter a grade of %name% to start calculating GPA
echo.
echo Total grades: %n%
echo.
echo.
set /p t=GRADE?
cls
set /a it=%it%+%t%
set /a n=%n%+%an%
cls
echo [A]dd another grade
echo [D]one
choice /c AD /n
if %errorlevel% EQU 2 goto do
if %errorlevel% EQU 1 goto ret
:load
cls
echo Student has record.
echo What do you want to do?
echo [L]oad record
echo [D]elete record
echo.
choice /c LD /n
if %errorlevel% EQU 2 goto d
if %errorlevel% EQU 1 goto l
:d
cls
rmdir Data\G\%name% /q /s
goto ret
:l
cls
copy Data\G\%name%\g.gdos g.tmp
timeout -t 3 /nobreak >nul
NCH40 -d -p 1223987465PM g.tmp >nul
set /p it=<g.tmp
set /p n=<Data\G\%name%\n.gdos
del g.tmp /q
set /a gpa=%it%/%n%
set l=y
cls
echo Please confirm data value.
echo Type %gn%please.
echo.
set /p gn=
echo Loaded GPA: %gpa%
timeout -t 3 /nobreak >nul
goto ret
:do
cls
if not exist Data\G\%name%\ mkdir Data\G\%name%
cls
set /a gpa=%it%/%n%
cls
echo GPA: %gpa%
timeout -t 3 /nobreak >nul
cls
del Data\G\%name%\*.gdos /q
echo %n%>Data\G\%name%\n.gdos
echo %it%>Data\G\%name%\g.gdos
NCH40 -e -p 1223987465PM Data\G\%name%\g.gdos >nul
cls
echo %gpa%> Data\gpa.dat
exit /b
 
Top