Documentation .CMD .BAT .BTM

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Charles Dye

Super Moderator
Staff member
May 20, 2008
Albuquerque, NM
BTM files cannot modify themselves dynamically, a foul and hideous technique I haven't seen in years.

BTM files run faster. Usually the difference is invisible, but over a network (login scripts!) it can be dramatic.
May 26, 2008
My preference is to name batch files with a BTM extension only if they don't work in cmd.exe. (That is, only if they are using TCC specific functions or syntax.)
For batch files that work in cmd.exe I use the CMD extension. I never use BAT any more.

It would be kind of cool if I could figure out how to get TCC to execute all *.cmd batch files using cmd.exe directly (to avoid the instances where TCC isn't fully compatible with cmd syntax). Started a thread on this a while back but was never able to get it to work as I expected.

.BTM (load entire file in memory before executing, hence run quicker, can NOT modify dynamically,
.BAT (loads and runs file line by line, hence slower then .BTM, can modify dynamically,
.CMD (same as .BAT, extension is same as MSDos's CMD.EXE)

Anything else?
Nov 2, 2008
EXTPROC only works in CMD files. I make heavy use of extproc batches, where the external processor is a rexx script (usu weave.rex).

/* REXX */ only works in CMD files.
May 26, 2008
Interesting... I didn't know about EXTPROC before. But it doesn't seem to be working for me in v17.

test.cmd contains:
EXTPROC C:\Windows\System32\cmd.exe

dir c:\
But when I run from TCC, I get:
C:\> test.cmd
TCC: Unknown command "C:\Windows\System32\cmd.exeC:\test.cmd"
There is no space between cmd.exe and C:\test.cmd. (And yeah, I'm aware that cmd.exe doesn't ignore EXTPROC....)
Nov 2, 2008
EXTPROC and /* */ is inherited from OS/2 cmd.exe, by way of 4os2 to 4nt.

You can write command processors in REXX, and then have the data file in a .CMD file. REXX scripts work fine as extproc command processors. I have a kind of home grown WEAVE (see Donald Knuth), which processes .CMD files by weave, and writes nicely synched sets of files, all without a hint of comment, because in literate programming, such as by DK and myself, you write the process as a paper, and syphon out stuff to compile/run.
Nov 2, 2008
This is a sample batch extproc and .cmd file, the sort of thing i make a good deal of use of.

Suppose you have a REXX script like SIMPCALC.REX

/* REXX */
numeric digits 20
parse arg infile
call stream infile, 'c', 'open read'
outfile = "temp.txt" ; call stream outfile, 'c', 'open write replace'
do while lines(infile)
  incard = linein(infile)
  parse var incard 1 cx 2 tail
    when cx = ';' then break
    when cx = '=' then interpret 'outcard='tail
    otherwise ; outcard = tail ; end
call lineout outfile, outcard
call stream infile, 'c', 'close'
call stream outfile, 'c', 'close'
You then can write a text file into a CMD file, and have rexx produce the output

EXTPROC simpcalc.rex
; goto :eof
;  Inline calculator
= 0.3048*3
= o.3048*66
This is an External processor simpcalc.rex, and one of its command files. Using a slightly greater parsing process, one can get it to print out fully formatted tables, for different measuring systems. The tables in actually reside in an EXTPROC batch, where

constants ko

produces this table in the measurement system 'ko', and a different command "constants mks" will produce the same in MKS.

The expanded extproc command is regina.exe systemx.rex constants.cmd ko, the systemx.rex by extproc, and regina.exe by set .rex=regina.exe
Sep 11, 2009
Portland, Or.
I was searching for a possible way to add the filetype of REX (or REXX) to the existing executables, like; EXE, BAT, CMD .. etc..
I added both REX & REXX to PATHEXT, but just entering "TEST" (for my simple TEST.REX file), at the command prompt, does not execute
the TEST.REX. Entering "TEST.REX" does execute it.

I'd like to add .rex & .rexx as extensions that do not need to be typed with the filename, and have ASSOC & FTYPE handle my rex
processor without specifying the extension, but haven't found it.

I found the above post about a CMD file having /* ... */ in the first line calling the rex processor so I renamed that my TEST.REX file to TRY.CMD
but when I entered "TRY" (without the extension), it *crashed* TakeCommand ! ! ..

Bug? Misunderstanding? Or? I'm still on R11 of TC.

Is there a way to add .rex to the list of executables that DON'T need the extension explicitly added?

-- update.. Don't know why I had that crash.. Brought TC back up and the "/*...*/" bit works now ? .. sigh.... stuff happens
Last edited:
Nov 2, 2008
None of JP processors have rexx bundled with them, but there are two excellent ones out there: Regina.rexx (which is classic rexx), and OORexx (object orientated rexx). You have to install one of these, or at least extract the various executables. Lua seems to be the first bundled processor, but you wonder why they don't just provide a lua interface, eg (tcc.wildspec) and let people download their own lua?

You need at a minimum, regina.dll and regina.exe, but there are other DLLs worth getting, such as Patrick McPhee's W32UTIL and SYSUTILS (now in regina). Documentation is in PDF, but quite servicable. (I use a windows IPF viewer, and the DOSREXX.INF from PC-DOS 7 for my needs.

I use regina rexx. Once this is installed, and 'assoc .rex' gives a decent answer, you can indeed do things like add .REX to the PATHEXT environment, or `set .rex=regina.exe`. It even works (gosh), if you put .REX in the string built into cmd.exe. But you have to provide your own rexx processor!

EXTPROC works with rexx scripts. The example in the 4NT.HLP file suggests that there is an EXE file processing it, but you can use a grotty REXX script to do it. This means, for example, that ye can write up a line-processing calculator, and have nice formatted documents with calculations from a rough list of names and equations.

REXX was IBM's glue language, and all command processors were supposed to be able to run batch files written in REXX. This is why you see .CMD and .BAT files designed to run REXX if they start /*. It's a nice language, but don't expect to do anything stupid like calculating the array suffix in place (ie T =P.(X-1) does not work, but Y=X-1; T=P.Y gives the right answer.)
Last edited:
Nov 2, 2008
Re adding .REX to the PATHEXT. Works under tcc 16/17/18 under Windows 6.3 (8.1 by the box),

Have not tried EXTPROC in this, i mainly use 4NT/TCMD 8.01 on Windows 2000 on the main iron.
  1. Download and install Regina Rexx or OOREXX.
  2. Install. Associate .REX to regina.exe (or rexx.exe)
  3. Edit PATHEXT to include .REX
  4. New cmd.exe sessions will then run .rexx
  • Alternately, `set .rexx=regina.rex` works in 4NT but not CMD