[net.micro.amiga] Keyword arguments in batch files

carolyn@cbmvax.cbm.UUCP (Carolyn Scheppner) (08/16/86)

           Keyword Arguments for Amiga Batch Command Files
           -----------------------------------------------

   The CLI Execute command has the capability of passing both positional
and keyword parameters to a batch command file. 

   Keyword parameters are set in the Execute command line by assigning
values to variables with the same names as the arguments in the .key
line of the batch file.  Default values can be assigned within the
batch file and command line assignments may be used to replace
any or all of the default values.  The following listings show the use
of keyword parameters in my cc script.  I have a single cc script
that is executed by one-line special purpose scripts.  The one-liners
modify the default values of the cc for Amiga compile, Amiga compile
and link, Lattice compile, Lattice compile and link, and compile then
Atomize.  I have also used one-liners to specify additional object
modules or libraries for the cc's Alink.  Usage of the one-liners
is (for example) ex lcl filename (to compile and link filename.c).

   I have included a listing of my startup-sequence which does some
of the setup for my scripts.  Also note that all of the commands for
compiling are in my c directory, I have a lib directory containing
all startup.obj's and .lib's, all scripts are in my s directory, and
I have renamed c:Execute to c:ex.  My startup cd's me to ram: where
I usually work.  The scripts compile files in your current directory
unless given a specific path on a filename.  In addition, I have
included a script called swapsys (usage - swapsys volumename:).
I use this script to switch to all control to another system disk
(such as my assembler system disk) without rebooting. 
 
                                 Carolyn Scheppner  CBM

----- file s:cc ----------------------------------------------------------
.key fn/a,lc1flags,lc2flags,atomize,atomopts,startup,ofiles,
 libraries,linkopts,nolink,linkonly,dsave
. === NOTE - The two lines above must be typed as a single long line ===

.def startup   "LIB:Lstartup.obj"
.def libraries "LIB:LC.lib,LIB:Amiga.lib"
.def atomize   "0"
.def nolink    "0"
.def linkonly  "0"
.def dsave     "0"


.  ===================================================================
.     Compile (Link) Single C Source File    C. Scheppner  v 1.1
.  ===================================================================

if <fn> eq "usage"
   echo " "
   echo "USAGE:  ex(ecute) cc filename [string=value]... [flag=value]..."
   echo " "
   echo "  Defaults:"
   echo "     Strings: lc1flags  = <lc1flags>"
   echo "              lc2flags  = <lc2flags>"
   echo "              atomopts  = <atomopts>"
   echo "              startup   = <startup>"
   echo "              ofiles    = <ofiles>(other than filename.o)"
   echo "              libraries = <libraries>"
   echo "              linkopts  = <linkopts>"
   echo "     Flags:   atomize   = <atomize>"
   echo "              nolink    = <nolink>"
   echo "              linkonly  = <linkonly>"
   echo "              dsave     = <dsave>"
   echo " "
   echo "Set flags to 0 (FALSE) or 1 (TRUE)"
   echo "Set other arguments to desired string"
   echo " "
   skip done
endif


. ===== Directory assignments =====
assign T:    :T
assign LIB:  df0:lib

. ===== Skip to link if linkonly=1 =====
if <linkonly> eq "1"
   skip link
endif

. ===== Abort if source file not found =====
if not exists <fn>.c
echo "File <fn>.c does not exist."
skip abort
endif

. ===== Save source to temp disk file if dsave=1 =====
if <dsave> eq "1"
   if exists df1:t
      echo "Copying <fn>.c to df1:t/lastcc.c"
      copy <fn>.c to df1:t/lastcc.c
   endif
endif

. ===== If old .q or .o files exist, delete them =====
if exists <fn>.q
   delete <fn>.q
endif
if exists <fn>.o
   delete <fn>.o
endif

. ===== First compiler pass =====
echo " "
lc1 <lc1flags> -idf1:include/ <fn>

. ===== Check for failure =====
if not exists <fn>.q
   echo " "
   echo "LC1 failed.  ABORTING CC ..."
skip abort
endif

. ===== Second compiler pass =====
echo " "
lc2 <lc2flags> <fn>

. ===== Check for failure =====
if not exists <fn>.o
   echo " "
   echo "LC2 failed.  ABORTING CC ..."
skip abort
endif

. ===== Atomize object if atomize=1 =====
if <atomize> eq "1"
   echo " "
   echo "Atomizing <fn>.o ..."
   rename <fn>.o <fn>.preAtom
   Atom <fn>.preAtom <fn>.o <atomopts>
endif

. ===== Save object to temp disk file if dsave=1, nolink=1  =====
if <dsave> eq "1"
   if <nolink> eq "1"
      if exists df1:t
         echo "Copying <fn>.o to df1:t/lastcc.o"
         copy <fn>.o to df1:t/lastcc.o
      endif
   endif
endif

. ===== Alink if nolink=0 =====
lab link
if <nolink> eq "0"
   echo " "
   alink <startup>,<fn>.o,<ofiles> TO <fn> LIBRARY <libraries> <linkopts>
endif

. ===== Save executable to temp disk file if dsave=1 =====
if <dsave> eq "1"
   if exists df1:t
      echo " "
      echo "Copying executable to df1:t/lastcc.exe..."
      copy <fn> to df1:t/lastcc.exe
   endif
endif

. ===== Successful CC =====
echo " "
echo "CC <fn> DONE"
skip done

. ===== CC Failed =====
lab abort
echo " "
echo "CC <fn> FAILED"

lab done


----- file s:ac ----------------------------------------------------------
.key fn/a

. ===== Amiga compile only single C source (stack-checking disabled) =====

ex cc <fn> lc2flags="-v" nolink=1

----- file s:ac.atom -----------------------------------------------------
.key fn/a

. ===== Lattice compile and atomize single C source file =====

ex cc <fn> lc2flags="-v" nolink=1 atomize=1 atomopts="-I"

----- file s:acl ---------------------------------------------------------
.key fn/a

. ===== Amiga compile and link single C source file =====

ex cc <fn> lc2flags="-v" startup=LIB:AStartup.obj libraries=LIB:Amiga.lib

----- file s:lc ----------------------------------------------------------
.key fn/a

. ===== Lattice compile only single C source file =====

ex cc <fn> nolink=1

----- file s:lc.atom -----------------------------------------------------
.key fn/a

. ===== Lattice compile and atomize single C source file =====

ex cc <fn> nolink=1 atomize=1 atomopts="-I"

----- file s:lcl ---------------------------------------------------------
.key fn/a

. ===== Lattice compile and link single C source file =====

ex cc <fn> startup=LIB:LStartup.obj libraries="LIB:LC.lib,LIB:Amiga.lib"

----- file s:startup-sequence --------------------------------------------
echo "CSYS1.2B8"
echo " "
stack 10000
cd ram:
makedir ram:t
assign   T: ram:t
assign LIB: df0:lib

----- file s:swapsys -----------------------------------------------------
.key volumename/a

. Swap development system disks   USAGE: ex(ecute) SwapSys volumename

assign C:      <volumename>:c
assign SYS:    <volumename>:
assign S:      <volumename>:s
assign L:      <volumename>:l
assign FONTS:  <volumename>:fonts
assign DEVS:   <volumename>:devs
assign LIBS:   <volumename>:libs
if exists <volumename>:lib
   assign LIB: <volumename>:lib
endif

-----------------------------------------------------------------------

   
   
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Carolyn Scheppner -- CBM   >>Amiga Technical Support<<
                     UUCP  ...{allegra,caip,ihnp4,seismo}!cbmvax!carolyn 
                     PHONE 215-431-9180
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

higgin@cbmvax.cbm.UUCP (Paul Higginbottom) (08/16/86)

In article <636@cbmvax.cbmvax.cbm.UUCP> carolyn@cbmvax.UUCP (Carolyn Scheppner) writes:

... intro to Keyword arguments for Amiga Batch Command files ...
... loads of script files follow describing how Carolyn does cc's and
links with various configurations of the Lattice compiler ... very
thoroughly documented, and useful for Lattice users, no doubt, I might add.

Sample...

>.  ===================================================================
>.     Compile (Link) Single C Source File    C. Scheppner  v 1.1
>.  ===================================================================
>
>if <fn> eq "usage"
>   echo " "
>   echo "USAGE:  ex(ecute) cc filename [string=value]... [flag=value]..."
>   echo " "
>   .
>   .
>   echo "Set other arguments to desired string"
>   echo " "
>   skip done
>endif
>
>. ===== Directory assignments =====
>assign T:    :T
>assign LIB:  df0:lib
>
>. ===== Skip to link if linkonly=1 =====
>if <linkonly> eq "1"
>   skip link
>endif
>
>. ===== Abort if source file not found =====
>if not exists <fn>.c
>echo "File <fn>.c does not exist."
>skip abort
>endif
>
>. ===== Save source to temp disk file if dsave=1 =====
>if <dsave> eq "1"
>   if exists df1:t
>      echo "Copying <fn>.c to df1:t/lastcc.c"
>      copy <fn>.c to df1:t/lastcc.c
>   endif
>endif
>
>. ===== If old .q or .o files exist, delete them =====
>if exists <fn>.q
>   delete <fn>.q
>endif
>if exists <fn>.o
>   delete <fn>.o
>endif
>
>. ===== First compiler pass =====
>echo " "
>lc1 <lc1flags> -idf1:include/ <fn>
>
>. ===== Check for failure =====
>if not exists <fn>.q
>   echo " "
>   echo "LC1 failed.  ABORTING CC ..."
>skip abort
>endif
>
>. ===== Second compiler pass =====
>echo " "
>lc2 <lc2flags> <fn>
>
>. ===== Check for failure =====
>if not exists <fn>.o
>   echo " "
>   echo "LC2 failed.  ABORTING CC ..."
>skip abort
>endif
>
>. ===== Atomize object if atomize=1 =====
>if <atomize> eq "1"
>   echo " "
>   echo "Atomizing <fn>.o ..."
>   rename <fn>.o <fn>.preAtom
>   Atom <fn>.preAtom <fn>.o <atomopts>
>endif
>
>. ===== Save object to temp disk file if dsave=1, nolink=1  =====
>if <dsave> eq "1"
>   if <nolink> eq "1"
>      if exists df1:t
>         echo "Copying <fn>.o to df1:t/lastcc.o"
>         copy <fn>.o to df1:t/lastcc.o
>      endif
>   endif
>endif
>
>. ===== Alink if nolink=0 =====
>lab link
>if <nolink> eq "0"
>   echo " "
>   alink <startup>,<fn>.o,<ofiles> TO <fn> LIBRARY <libraries> <linkopts>
>endif
>
>. ===== Save executable to temp disk file if dsave=1 =====
>if <dsave> eq "1"
>   if exists df1:t
>      echo " "
>      echo "Copying executable to df1:t/lastcc.exe..."
>      copy <fn> to df1:t/lastcc.exe
>   endif
>endif
>
>. ===== Successful CC =====
>echo " "
>echo "CC <fn> DONE"
>skip done
>
>. ===== CC Failed =====
>lab abort
>echo " "
>echo "CC <fn> FAILED"
>
>lab done
>

 ... and so on, and so on for at least another 50 lines...

>-- 
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>Carolyn Scheppner -- CBM   >>Amiga Technical Support<<
>                     UUCP  ...{allegra,caip,ihnp4,seismo}!cbmvax!carolyn 
>                     PHONE 215-431-9180
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

This has nothing to do with Carolyn's EXCELLENT description of how to
really utilize script files on the Amiga, but, but, but....

Doesn't this remind you of the difference between VMS and UNIX?

I personally accomplish most of the above by typing in:

	make

On my Aztec system.

	Lightheartedly yours,
		Paul.

Disclaimer: I do not work for Commodore, and the opinions above are my own.

walker@sas.UUCP (Doug Walker) (08/19/86)

In article <638@cbmvax.cbmvax.cbm.UUCP>, higgin@cbmvax.UUCP writes:
> 
> I personally accomplish most of the above by typing in:
> 
> 	make
> 
> On my Aztec system.
> 
> 	Lightheartedly yours,
> 		Paul.

And I personally accomplish it by typing

	make

on my Lattice system.  Why does Aztec have a monopoly on make?

PS - that's really an unfair comparison, too, since you need to
     have typed in a makefile to REALLY get what her script
     does.

If anybody is interested in a 14K near-perfect UN*X make, phone
(919)471-6436 300/1200/2400 baud.  Or ask for it when mailing
Jack Rouse for Kermit or John Toebes for HACK.

higgin@cbmvax.cbm.UUCP (Paul Higginbottom) (08/21/86)

>And I personally accomplish it by typing
>
>	make
>
>on my Lattice system.  Why does Aztec have a monopoly on make?
>
>PS - that's really an unfair comparison, too, since you need to
>     have typed in a makefile to REALLY get what her script
>     does.
>
>If anybody is interested in a 14K near-perfect UN*X make, phone
>(919)471-6436 300/1200/2400 baud.  Or ask for it when mailing
>Jack Rouse for Kermit or John Toebes for HACK.

I assume by your offer at the bottom that this 14K make you have is NOT
the one sold by Lattice.  My "lighthearted" comments (which I did claim as
such) were not intended to say that Manx 'has a monopoly on make' (your
words) because I did (and still do) use a UNIX system before I used the
Manx system for the Amiga.  Yes, you would have to create a makefile, but
a real 'make's built-in rules do make the job easier than Carolyn's batch
file, you must admit.

Anyway, let's not fight about this, it's not worth it - you make the best
of the system you have.  Carolyn showed an excellent example of how to
customize a Lattice system, I was just make an [albeit inaccurate] crack
about make making the job easier, which you also took out of context because
it was also mentioned re: a VMS / Unix yuk-yuk.

	Ho hum,
		Paul.

Disclaimer: I can't help my sense of humor, I do not work for Commodore, and
no-one I know has opinions like mine.