forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

BAT syntax

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 2816
Location: South Pole, Antarctica

PostPosted: Mon Aug 16, 2010 11:10 am    Post subject: BAT syntax Reply with quote

Can folks here with BAT file syntax knowledge suggest me how to improve my compilation bat files?

What i like to have is the following. I need the compiling file COMP.BAT to take compilation options depending on arguments. For example

C:> COMP.BAT n - when i want all files compiled with /NOCHECK option
C:> COMP.BAT n z - when compile with /NOCHECK and /ZERIOSE option
C:> COMP.BAT f - to compile with /FULL_DEBUG
C:> COMP.BAT f u - with /FULL_DEBUG and /UNDEF

etcetc. You've got the idea.

Right now i do that only by using such syntax

C:>COMP.BAT f z

if (%1)==(f) goto PATH_F
if (%1)==(u) goto PATH_U
if (%1)==(fu) goto PATH_FU
....
if (%2)==(z) goto PATH_z
.....

where
- %1, %2 are first, second and so on arguments after the bat file name,
- PATH_F, PATH_U etc are the labels inside COMP.BAT where a bunch of files compiled with say /FULL_DEBUG like that

:PATHF
ftn95 F:\Folder1\_FMAIN11\CodeU.FOR /fixed /check /full_debug /zeroise /statistics /binary CodeW.obj >zCodeU
ftn95 F:\Folder1\_FMAIN11\CodeV.FOR /fixed /check /full_debug /zeroise /statistics /binary CodeV.obj >zCodeV
ftn95 F:\Folder1\_FMAIN11\CodeW.FOR /fixed /check /full_debug /zeroise /statistics /binary CodeU.obj >zCodeW
..............
.............

or with /UNDEF switch

:PATHFU
ftn95 F:\Folder1\_FMAIN11\CodeU.FOR /fixed /check /full_debug /UNDEF /zeroise /statistics /binary CodeW.obj >zCodeU
............
...........
.........

Means i do things looooong way, programming everything in bat file while it would be easy just somehow (i do not know how) to do that like this (i am just guessing)

C:> COMP.BAT n z k

and inside of this bat file

FTN95 MYPROJ1.F95 #1 #3
FTN95 MYPROJ2.F95 #1 #2 #3
FTN95 MYPROJ3.F95 #1 #2 #3 #4
.......

where
#1 #2 #3 etc are my options ( /FULL_DEBUG , /NOCHECK, /ZEROISE etc)
and that would be all. 100 times less typing and 10000000 times less mess. Possible?
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Thu Aug 19, 2010 1:04 pm    Post subject: Reply with quote

Dan,

I've never known if I have a poor understanding of the commands available in *.bat files, or there are few effective commands available.
I have written only a few batch files that can do little more that list commands and the ones I have written were very long to do so little.
You can have local variables and goto statements.
I never perfected the for loop.

Maybe someone may know how to use batch commands ?? although there have been no other replies.

I recall that Apollo workstations had a simple and more effective batch file which included redirecting command input to the batch file. I miss that.

Anyway, the following is a cut down batch command I wrote about 10 years ago. I've done things differently since. It might be of some help ??

Code:
@echo off
rem  batch file to run stage 3a test options
rem
echo berth option %2  train option %3  yard option %4  report label %5
rem  copy data files that are to be used for this run
rem
@echo on
copy d:\sim\pwcs.dir\stage3.dat\minenco.98\berth97.%2 berth.dat
copy d:\sim\pwcs.dir\stage3.dat\minenco.98\train97.%3 train.dat
copy d:\sim\pwcs.dir\stage3.dat\minenco.98\macop98.%4 macop.dat
@echo off
rem
rem  ship stems are d:\sim\pwcs.dir\stage3.dat\ships\ship95?.%1
set ship=d:\sim\pwcs.dir\stage3.dat\ships\ship95
REM set exe=d:\sim\pwcs.dir\source\pwcs.98\macop
rem set exe=d:\sim\pwcs.dir\source.f95\pwcs.dev\macop_b
set exe=d:\sim\pwcs.dir\source.f95\work.dev\macop_b
echo using %exe% module
rem
rem  set the mtpa and stem variables
rem
if %1==80 goto m80
if %1==84 goto m84
if %1==88 goto m88
if %1==92 goto m92
if %1==96 goto m96
echo did not find yem %1
goto end
 
:m80
set mtpa=80
set s1=F
set s2=G
set s3=I
set s4=L
goto run
 
:m84
set mtpa=84
set s1=B
set s2=C
set s3=E
set s4=H
goto run
 
:m88
set mtpa=88
set s1=A
set s2=C
set s3=E
set s4=F
goto run
 
:m92
set mtpa=92
set s1=A
set s2=B
set s3=C
set s4=E
goto run
 
:m96
set mtpa=96
set s1=B
set s2=F
set s3=I
set s4=K
goto run
 
rem now run the 4 stems for this option
 
:run
echo command to run 4 ship files for %1 mtpa %s1% %s2% %s3% %s4% - STAGE 3-TRY3
rem  berth option %2  train option %3  yard option %4  report label %5
rem if exist lotus.out del *.out
rem *.bin
 
echo  run ship stem 1 - %ship%%s1%.%1 for %1 mtpa
copy %ship%%s1%.%1 ship.bin
now
%exe%  <macop97.txt >macop.tce
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2816
Location: South Pole, Antarctica

PostPosted: Fri Aug 20, 2010 10:38 am    Post subject: Reply with quote

Many thanks, John, you helped me so many times, i really owe you!
Yes, i found in your file exactly what i need! It's a shame i did not know that syntax.

And below is working prototype of approximately what i was asking for, may be somebody else will use it too for their complex batch files. This really simplifying things.

Suppose we have bunch of Fortran files, let's take just one for example aaa.for, which we need to compile. We create batch file b.bat

Code:
if (%1)==(f)  set s1=/full_debug
if (%1)==(u)  set s1=/undef
if (%1)==(n)  set s1=/nocheck /zeroise /statistics /silent /win
ftn95 aaa.for %s1%
slink aaa.obj


and call it

C:> b f ( if we want compile aaa with /full_debug switch )
C:> b u ( if we want /undef )

and if we just type
C:> b
the file will be compiled default way without switches and so on. Great help!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group