Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 11-07-2012, 02:12 PM   #1
Beta Member
 
Join Date: Nov 2012
Location: US
Posts: 2
Unhappy batch code broken?

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
__________________

PGspy18 is offline   Reply With Quote
Old 11-07-2012, 07:20 PM   #2
Beta Member
 
Join Date: Nov 2012
Location: US
Posts: 2
Default Re: batch code broken?

I should clarify.
it creates a n.peid, but when i open it up in notepad, its blank
PGspy18 is offline   Reply With Quote
Reply

Tags
batch

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 10:55 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0