How to? Script support

Oct 18, 2008
268
1
#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?
 
Oct 18, 2008
268
1
#3
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).
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
 

rconn

Administrator
Staff member
May 14, 2008
10,495
94
#4
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 –
That's true, except for REXX.

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?
Yes, REXX is a special case (a carryover from 4OS2).

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
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.
 
Oct 18, 2008
268
1
#5
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?
 

rconn

Administrator
Staff member
May 14, 2008
10,495
94
#6
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
Correct.

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

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,575
46
Albuquerque, NM
prospero.unm.edu
#7
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?
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.)
 
Oct 18, 2008
268
1
#8
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