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

How to? Script support

Discussion in 'Support' started by fpefpe, Sep 25, 2012.

  1. fpefpe

    Joined:
    Oct 18, 2008
    Messages:
    251
    Likes Received:
    1
    Hello -- sorry if this has been asked, but, say, if python and perl ( or tcl ) is turned on in the INI file, how does tcc figure out when processing a *.cmd file which processor (python, perl, tcc ) to use?
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,870
    Likes Received:
    83
    TCC normally uses the file's extension (.py, .pl, .tcl, etc.) to determine the processor.

    If you're using a .CMD extension for something other than a CMD or TCC batch file, TCC also includes EXTPROC / SHEBANG support (see the help for details).
     
  3. fpefpe

    Joined:
    Oct 18, 2008
    Messages:
    251
    Likes Received:
    1
    Hello – thanks for the reply .... I was looking at the extproc / shebang hellp but the doc lead me to believe that what ever the command is noted on the first line in the file, the specified file would run as a child process to tcc, thus would not be able to change the environment owned by the TCC parent –

    I been using rexx support for years and have many *.cmd file that are rexx scripts – I do start each *.cmd file with a rexx comment – is that the TCC trigger to process the file with rexx?

    Lastly, unless there is a a custom version of a command , if file containing EXTPROC in the first line, would probable fail with a syntax error ... It would make more sense if that first line was imbedded in a comment
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,870
    Likes Received:
    83
    That's true, except for REXX.

    Yes, REXX is a special case (a carryover from 4OS2).

    I don't know what you're asking. TCC knows what EXTPROC means, and it uses the EXTPROC argument as the command to execute (passing the filename as the command's argument). If you provide a bad argument, then you'll get a syntax error. This syntax is about 20 years old, and definitely cannot be changed without breaking every batch file that's using EXTPROC.

    But CMD.EXE won't support EXTPROC.
     
  5. fpefpe

    Joined:
    Oct 18, 2008
    Messages:
    251
    Likes Received:
    1
    Just to clarify, if tcc detects the “extproc” in the first line in the myfile.cmd and that first line is

    extproc c:\pascal\pascal.exe

    then, tcc closes myfile.cmd file and then executes

    c:\pascal\pascal.exe myfile.cmd

    I would think that unless this a custom version of pascal, it would it fail with a syntax error? Or does TCC some how pass a pointer to the file missing the first line?
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,870
    Likes Received:
    83
    Correct.

    That has nothing to do with TCC -- it's up to the command you execute to know how to deal with the .CMD file (including skipping the first line). Since CMD in Windows no longer supports EXTPROC / Shebang (though the Linux shells still do), it's rarely used anymore. But some users have custom apps that rely on it.
     
  7. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,312
    Likes Received:
    39
    Many scripting languages, particularly those ported from the Unix world, will recognize a shebang at the start of a file and treat it as a comment -- i.e. ignore it. (Pascal won't, but then Pascal isn't a scripting language.)
     
  8. fpefpe

    Joined:
    Oct 18, 2008
    Messages:
    251
    Likes Received:
    1
    umm ... As I understand it, if the first line in a "unix" shell script is "#!" then the next token is the executable for the shell to invoke to
    run "this" script file ... I thought that "#" is the comment indicator in many languages, and is that not the case for pascal? I know that
    tcl/tk works this way ... I have a short tcl/tk script in my cygwin environment to deal with window/dos files paths an then run a window base
    editor that does not know about "posix paths" -- but is happed when those paths then convert by the tcl script to "native" format and then
    having tcl run the editor
     
  9. David Marcus

    Joined:
    Jun 4, 2008
    Messages:
    648
    Likes Received:
    1
    No, it is not the case for Pascal. And, Pascal is not interpreted, so doesn't run scripts.
     

Share This Page