Home

Wednesday, December 24, 2008

Example of windows batch file

@ECHO OFF
REM - LABEL INDICATING THE BEGINNING OF THE DOCUMENT.
REM - Filename compile.bat
:BEGIN
REM CLS
REM - THIS SCRIPT IS DESIGN TO DO MASS COMPILE OF PASCAL USING CPM
REM - THE BELOW LINE COMPILE AND LINK *.PAS TO *.CMD FROM LIST C:\compile\PAS.log
REM - WRITTEN BY KH WONG (DATE 4/20/05)
REM - Latest modified BY KH WONG (DATE 1/8/07)

REM - To delete off all files inside the directory of after_compile and log
cd C:\compile\after_compile
del /Q *.*
cd C:\compile\log
del /Q *.*

REM - To copy the pas and fcn file out from the source directory to C:\compile base on pas.log and vector.log
cd C:\compile\source
for /F %%X in (C:\compile\pas.log) do copy %%X.pas C:\compile
for /F %%X in (C:\compile\vector.log) do copy %%X.fcn C:\compile

REM - Begin to compile the pas to cmd and copy the cmd to after_compile directory
REM - Do EPAS
cd C:\compile
echo "Compile Log File" >> Log\compile.log
for /F %%X in (pas.log) do cpm epas %%X >> Log\compile.log
echo "Link Log File" >> Log\link.log
for /F %%X in (pas.log) do cpm elink %%X,noressum,qspiralx >> Log\link.log
for /F %%X in (pas.log) do copy %%X.cmd after_compile
for /F %%X in (pas.log) do del /Q %%X.cmd
for /F %%X in (pas.log) do del /Q %%X.MAI
ECHO 

REM - Begin to compile the fcn to lff and copy the cmd to after_compile directory
REM - Do FUNCASM
echo "Link Log File" >> Log\funcasm.log
for /F %%Y in (vector.log) do cpm funcasm %%Y >> Log\funcasm.log
for /F %%Y in (vector.log) do copy %%Y.lff after_compile
for /F %%Y in (vector.log) do del /Q %%Y.lff

REM - To delete the pas and fcn file out from the source directory to C:\compile base on pas.log and vector.log
for /F %%X in (pas.log) do del %%X.pas
for /F %%X in (vector.log) do del %%X.fcn

copy tolower.exe after_compile
cd C:\compile\after_compile
tolower
del tolower.exe

No comments:

Post a Comment