         _________________________

         CutParam - (C) Ph.Dalleur

                1989 - 2000
         _________________________


 This little program called in a Batch File will split one of the command
 line parameters of the batch file. It is to be used with DOS system or
 console under Windows 3.x, 9x or 2000. Even if I used it 10 years ago, I
 think it can already be valuable. So I decided to give it for free on the
 net.

 Use:  CutParam [N[c]] [>redirection]

   where
   N = 0..9 is the number of the parameter to split
       the number must be in position 1 (one space after CutParam or
       CutParam.COM)
   c = optional splitting character (defaulted to period '.')
       The character must be in position 2. A valid character is each
       ascii caracter ranging from 33 ('!') to 255. Other characters
       are ignored.
   Redirection to NUL is possible to eliminate the error code messages.

 You do not need anymore to supply your filename without extension to
 a *.BAT file when it was asked to. If you call cutParam in a batch file
 you can cut this extension off, and use the name of the file without the
 extension to produce other files with the same name but with other
 extensions. You can also use the extension alone to trigger different
 extension dependant processes.

 Its cutting character defaults the period '.' so that it splits a
 filename parameter into its name and its type (extension). If the
 third parameter is "test.asm", the command "CUTPARAM 3" will set the
 third parameter to "test" and insert a 4th parameter "asm". The former
 4th and following parameters are shifted to the 5th and following
 ones. You can choose any other cutting character for example a '_' to
 split a parameter like "proj_001.prj" into "proj" and "001.prj". You
 simply put something like "CUTPARAM 1_" in your batch file to get the
 split. See examples below.

 CutParam can be handy for those who use command line compilers, linkers,
 installation or backup batch processes, etc., or those who would like to
 extend the automatic effect of some extension linked application starter
 found in Windows Explorer, Norton Commander or Windows Commander. If you
 use those capabilities, you will have noticed that it is easy to build your
 command line with shortcut keystrokes to enter the filename you selected.
 But by this way, you enter the extension as well, and it is sometimes good
 to get rid of it, to start processes using or generating the same filenames
 but with other extensions.

 Put CutParam.com in one of your PATH directories, and the game is over. It
 doesn't take even 1Kbyte! Use it only in batch files: it is not intended to
 be used on prompted command line. The command [CutParam 2 ] is equivalent
 to [CutParam 2. ].

 This program is free. But you use it at your own risk! I can not be
 made responsible for any (supposed) dammage done to your computer
 or your great-aunt. I ask you not to use it for immoral things, not
 to make money out of it, and if you want to diffuse it, do it with
 the package of these unchanged README.TXT and CUTPARAM.COM files
 (the source CUTPARAM.ASM may be added). If you use the source code,
 please be fair and mention where you have found it. I must congratulate
 the DOS system programmers and conceptors for their job and the
 information they supplied. The source code is adapted from old design
 to the NASM compiler (see http://www.cryogen.com/Nasm), but may be adapted
 to any Intel x86 compiler. In order to be universal, this program is usable
 from 8088 to the last Pentium III and compatibles, and from DOS 3.x to DOS
 console under WIN 98. I did not have the time yet to test it on Windows
 2000, but it should work fine.

 ---------
 Example 1
 ---------
 With this simple example you will easily understand the mechanics
 of CutParam. It splits argument 1 into arguments 1 and 2, shifting
 the following arguments to 3 and above.

 Let's take the copyback.bat file with the following lines:

---- COPYBACK.BAT ------
      @echo off
      echo BACKUP OF FILE %1
      CutParam 1>NUL
      echo The file %1.%2 will be copied to %1.BAK and NEW.%2
      copy %1.%2 %1.BAK
      copy %1.%2 NEW.%2
      echo Filename is [%1] and extension [%2]. %3
------------------------

 Now enter the following command at DOS prompt:

      copyback copyback.bat OK! (Enter)

 and it will create two files copyback.BAK and NEW.bat with the following
 messages:

      BACKUP OF FILE copyback.bat
      The file copyback.bat will be copied to copyback.BAK and NEW.bat
           1 file copied
           1 file copied
      Filename is [copyback] and extension [bat]. OK!

 ---------
 Example 2
 ---------
 You can even use the parameter 0, like with this version of copyback.bat
 file, entering the command line at Dos prompt:

      copyback.bat (Enter)

---- COPYBACK.BAT ------
      @echo off
      echo BACKUP OF FILE %0
      CutParam 0>NUL
      echo The file %0.%1 will be copied %0.BAK and copied to NEW.%1
      copy %0.%1 %0.BAK
      copy %0.%1 NEW.%1
      echo Parameter 2 = %2
------------------------

 Remark :
 - If you type in:
 
    copyback foo (Enter),
 
 you will create the files copyback.BAK and NEW (without extension), and
 the comment:
 
    Parameter 2 = foo
 
 Actually, the parameter 1 is then a null string.


 ---------
 Example 3
 ---------
 If you mention a character, you can split the argument differently.
 Say that you have several files like COPY_001.HTM, COPY_002.HTM,
 COPY_003.HTM, etc. COPY_001.TXT, COPY_002.TXT, etc. and PROJ_001.PRJ,
 PROJ_002.PRJ, etc. If you plan to make different compressed files of the
 series COPY and PROJ separately, you can use the following batch file.
 Simply enter one of the file names to get the right archive compressed.

---- ZIPPER.BAT -----
      @echo off
      CutParam 1_>NUL
      CutParam 2 >NUL
      echo Compressing files %1_xxx.%3 into %1_%3.ZIP
      pkzip %1%_3.ZIP %1_*.%3
------------------------

 You will generate COPY_HTM.ZIP, COPY_TXT.ZIP and PROJ_PRJ.ZIP
 respectively when you enter "ZIPPER COPY_001.HTM", "ZIPPER COPY_001.TXT"
 and "ZIPPER PROJ_001.PRJ".

 ---------
 Example 4
 ---------

 The following example is to be analysed by those who use(d) compilers.
 It uses the extension to jump to a file type dependant batch process,
 compiling ASM, CPP or C files. If the extension is not valid, you get
 a "Label not found" error message and exit immediately the batch
 process.

 If you enter "COMPILE MYCOM.ASM" it will produce a compiled object
 MYCOM.OBJ, link this last file consequently to get MYCOM.EXE and take
 the later file to produce MYCOM.COM. You see the cascading process is
 followed without need to extract the extension off. It is done by
 CutParam. You get an idea of what can be done with CPP and C files.

---- COMPILE.BAT ------
      @echo off
      CutParam 1 >NUL
      REM If the extension is not valid you exit the batch process
      REM with a "Label not found" error.
      goto %2

      :ASM
      echo [%1.%2] is an ASM program. Compiling...
      masm %1.%2;
      if errorlevel 1 goto exit
      echo Linking %1.obj
      link %1 ;
      choice Produce %1.COM
      if not errorlevel 2 exe2bin %1.exe %1.com
      goto exit

      :CPP
      echo [%1.%2] is a CPP program. Search for Resource file...
      if exist %1.rc rc %1.rc %1res.res
      call cpp %1.%2 %1res.res
      goto exit

      :C
      echo [%1.%2] is a C program. Search for Resource file...
      if exist %1.rc rc %1.rc %1.res
      call cpp %1.%2 %1.res
      goto exit

      :EXIT

----------

 To make this work, you should have another batch file cpp.bat
 which defines the compiling process of C and CPP files. It
 is only an example of what you can do with CutParam. You can
 put here direct command calls to your favourite compiler if you
 want. I simply don't want to side with or against any compiler
 manufacturer.



February 2000.
Email: phildal@hotmail.com
