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

Documentation .CMD .BAT .BTM

Discussion in 'Support' started by Charles G, Nov 12, 2014.

  1. Charles G

    Joined:
    Apr 2, 2011
    Messages:
    1,028
    Likes Received:
    0
    The help pages for all three are the same. Be great if they could be different and provide examples of what extension should work in what situations.
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,870
    Likes Received:
    83
    There is no difference (other than BTM files loading in memory), and they all work in all situations.
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,312
    Likes Received:
    39
    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.
     
  4. Rod Savard

    Joined:
    May 26, 2008
    Messages:
    481
    Likes Received:
    3
    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.
     
  5. Charles G

    Joined:
    Apr 2, 2011
    Messages:
    1,028
    Likes Received:
    0
    So:

    .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?
     
  6. w_krieger

    Joined:
    Nov 2, 2008
    Messages:
    176
    Likes Received:
    0
    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.
     
  7. Charles G

    Joined:
    Apr 2, 2011
    Messages:
    1,028
    Likes Received:
    0
    Stupid me but EXTPROC is ? I guess PROC is Procedure so EXT is either EXIT or EXTEERNAL...?
     
  8. JohnQSmith

    Joined:
    Jan 19, 2011
    Messages:
    559
    Likes Received:
    7
  9. Charles G

    Joined:
    Apr 2, 2011
    Messages:
    1,028
    Likes Received:
    0
    Thanks JohnQSmith
     
  10. Rod Savard

    Joined:
    May 26, 2008
    Messages:
    481
    Likes Received:
    3
    Interesting... I didn't know about EXTPROC before. But it doesn't seem to be working for me in v17.

    test.cmd contains:
    Code:
    EXTPROC C:\Windows\System32\cmd.exe
    
    dir c:\
    But when I run from TCC, I get:
    Code:
    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....)
     
  11. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,870
    Likes Received:
    83
    Fixed in build 54.
     
  12. w_krieger

    Joined:
    Nov 2, 2008
    Messages:
    176
    Likes Received:
    0
    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.
     
  13. w_krieger

    Joined:
    Nov 2, 2008
    Messages:
    176
    Likes Received:
    0
    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

    Code:
    /* 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
      select
        when cx = ';' then break
        when cx = '=' then interpret 'outcard='tail
        otherwise ; outcard = tail ; end
    call lineout outfile, outcard
    end
    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

    Code:
    EXTPROC simpcalc.rex
    ; goto :eof
    ;
    ;  Inline calculator
      foot
    =0.3048
      yard
    = 0.3048*3
      chain
    = 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 http://z13.invisionfree.com/DozensOnline/index.php?showtopic=872 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
     
  14. BobK

    Joined:
    Sep 11, 2009
    Messages:
    35
    Likes Received:
    0
    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
     
    #14 BobK, Jul 4, 2015
    Last edited: Jul 4, 2015
  15. w_krieger

    Joined:
    Nov 2, 2008
    Messages:
    176
    Likes Received:
    0
    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.)
     
    #15 w_krieger, Jul 5, 2015
    Last edited: Jul 5, 2015
  16. w_krieger

    Joined:
    Nov 2, 2008
    Messages:
    176
    Likes Received:
    0
    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
     

Share This Page