home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
misc2
/
tcl.lzh
/
TCLV11.DOC
< prev
next >
Wrap
Text File
|
1984-08-31
|
23KB
|
953 lines
This is a haphazard description of the new features of TCL V1.1. I hope it
helps. I'll be monitoring the TCL notes file and will be happy to explain
specific things. I'm still looking for new suggestions. I suspect (and hope)
that with the wealth of new features, some of you will come up with even
cooler things to add. I found that every time I added something new and
started to use it in macros, it prompted me to think of another feature to
add. Necessity is the mother of invention, don't you know. I'm so boggled with
work right now there are a lot of things that will have to wait. I'm sorry
about the incompleteness of all this but I hate to be the perpetrator of more
Vaporware so here goes.
Ted
-------------------------------------------------------------------------------
When using ESET to set PATH=, it was possible to enter lower case strings
for the pathspecs. Command.com hates this, so now TCL detects setting of
PATH= and converts the value to upper case.
A bad chdir or cd command now shows an error.
_______________________________________________________________________________
Help is no longer available. I didn't like the way it was done, so I disabled
it and I'm working on a seperate help utility more like the VMS help facility.
_______________________________________________________________________________
TCL has command line switches for things. Currently available are the following:
-i tells TCL it's running on an IBM instead of a Rainbow - this makes command
line editing work right and also CLS. On an IBM machine, the following
IBM keyboard to Rainbow equivalent translations are performed:
PgUp = Prev Screen
PgDn = Next Screen
End = Select
F1 = Do
Arrows as you'd expect
On IBM, Insert key will toggle insert mode as well as control-A
-m<path> tells TCL that the macro file to use is <path> - if you just type
-m or -mnothing, no macro file accesses are attempted.
-r tells TCL not to do I/O redirection - let command.com do such commands
I'm having trouble with this one. First, I haven't implemented pipes yet.
Second, I can't seem to restore stdout on my AT. So when running on an
IBM machine, I always set -r. On a Rainbow, don't use -r. This will allow
you to redirect I/O from installed names. Also, don't do output redirect
to a device (like NUL or PRN) with a single right angle bracket. Use double
brackets (which means append). You may have guessed from all this that
I'm working on eliminating the necessity of COMMAND.COM altogether.
-p run in permanent mode - this is useful for running TCL as your SHELL
from CONFIG.SYS. Exit is disallowed. (BTW - TCL traps control-c now so you
can't accidentally lose all your stuff and have to start it again.)
-l<num> defines the amount of space to set aside for logical names. Default is
2048 bytes. If you don't use many, save space and reduce it.
-e<num> defines the environment size. Default is 2048. !!!Not implemented yet.
Here is my Rainbow config.sys line
shell=f:\tasks\tcl.exe -pmf:\tcl\startup.tcl
and my AT config.sys line
shell=c:\tasks\tcl.exe -pirm\tcl\startup.tcl
_______________________________________________________________________________
There are a bunch of new ways to output text to the console:
WRITE -
This was in V1.0 but it works differently now. It understands 'C'
language style escape sequences (i.e. beginning with a backslash).
\n - output CR-LF
\t - horizontal tab
\s - a space
\e - the 'escape' character (dec. 27)
\ddd - ascii code in decimal (first character not = 0)
\0ddd - ascii code in octal
This command does not automatically print a newline anymore
WARNING: Don't print file specs with this - the backslashes get screwed up
WRITELN -
same as WRITE but does the newline automatically at the end
WRITENI -
same as WRITE but escape sequences are not interpreted - use this to
display filespecs
PWRITE -
similar to WRITE - however, escape sequences are initiated with the '$'
character and are interpreted the same way the the PROMPT environment
string defines them (This is how TCL prints your prompt)
By the way, TCL prints a newline before the prompt. Also, it no longer adds
an asterisk to the prompt. If you still want that (as I do) redefine the
prompt at startup. There is an easy way to do this which brings me to
_______________________________________________________________________________
!! ENVIRONMENT VARIABLES !!
Anywhere you want to use the value of an environment string, use the name
of the string surrounded by percent signs. For example, to show the current
value of comspec from a macro designed for this purpose do
def comspec? writeni Comspec is currently set to %comspec%.
then type
comspec?
A macro which appends a new path to your path string is
def addpath eset path=%path%;%1
To add an asterisk to your prompt do
eset prompt=*%prompt%
If the environment variable is undefined, the %whatever% is simply deleted.
_______________________________________________________________________________
Macro stuff:
The name of a macro can now be written on the same line as the <SOH> or
control-A in the macro file and the case doesn't matter anymore.
Macro names cannot exceed eight letters.
Macro definitions cannot exceed 1000 characters (including newlines).
You can redefine all sorts of things to make them smarter by defining a
macro with the same name. For example, if you use some utility named FOOBAR
which is defined as an installed name you can override the installed name
and use a macro to give common switches specified in an environment string.
Suppose you always type
foobar /switch1 /switch2=something filespec
you can reduce this to
foobar filespec
like this
eset foobar=/switch1 /switch2=something
def foobar .foobar %foobar% %1
The period at the beginning of the line tells TCL to ignore a macro of the
same name and use the normal rules governing the determination of what to
do.
_______________________________________________________________________________
New commands!
These commands can be typed in upper or lower case.
GOTO -
A label in TCL is any string of nonwhitespace characters beginning with
a colon and occuring at the beginning of a line. You use goto to get there.
looper {this is a do-nothing macro which is usefule for
:loop goto loop {proving that TCL can detect control-C in a macro and
{do the right thing - what it does is ask you if you
{want to terminate the macro - neat huh? Try it.
RETURN -
Return to caller of this macro.
ABORT -
Cancels all macro processing, no matter how many levels deep.
COM -
Pass the rest of the line directly to command.com without further
interpretation.
Example: here is a macro which will bypass TCL HELP
def help com help %*
_______________________________________________________________________________
Conditional operators:
All conditional operators are invoked by typing a '?' followed by the
conditional name. If the condition is false, the rest of the line is
ignored. Otherwise the rest of the line is executed. If a '^' follows the '?',
the reverse is done. (The '^' indicates you want the negation of the condition)
Some of these operators are more useful for their side effects. Still, they
all evaluate to true or false.
EQU -
Looks at the next 2 tokens and skips the rest of the line if they are
not exactly equal.
?equ yes yes writeln Yes equals yes.
?equ %1. yes. writeln First argument equals yes.
?^equ %1. . writeln The first argument isn't null.
Note that the last two examples have periods stuck in. This is so that
even if the %1 is empty, it still evaluates to a recognizable token. If
you were trying to check the value of an environment string like this:
?^equ %foo% bar goto somewhere
and foo wasn't defined, the line would evaluate to
?^equ bar goto somewhere
"bar" and "goto" would be compared and then the statement "somewhere"
would be executed - not exactly what you want.
But with this
?^equ %foo%. bar. goto somewhere
then foo=bar would result in ?^equ bar. bar. goto somewhere
and foo= would result in ?^equ . bar. goto somewhere
Get it?
SIM -
Compares strings without regard to case - stands for "similar".
FIRST -
Stores the first character of a token in an environment variable.
?first Yes yesno {result: yesno=Y
INPUT -
Assumes the first token is the name of an environment string. User input
is taken from the console and the string entered by the user is stored
as the value of the environment variable. Evaluates to true if the
user types anything. (Except just whitespace) The user input goes into
the command line recall ring. This is so that responses to a macro which
is re-issued can be recalled.
Here is a macro that will prompt the user for input.
pfi {<prompt string> <environment variable>
:loop write %1
?input %2 return
writeln Sorry, null response is not permitted - try again.
goto loop
CLEAR -
takes one or more environment variable names and deletes them - always
evaluates to true
?clear alpha beta gamma
which is the same as doing
eset alpha=
eset beta=
eset gamma=
NULL -
Assumes the first token is the name of an environment string. Evaluates
to true if the environment string isn't defined.
Here is some code which makes sure comspec is defined and asks for it
if it isn't.
:loop ?^null comspec goto ok {compsec set? then do nothing
writeln Hey! you forgot to define comspec=.
pfi What\sshould\sit\sbe?\s\s comspec {use pfi macro from above
:ok
{note that \s is used instead of spaces because the intent
{is to pass all four words as a single token
{someday, I'll implement quotes
FBUILD -
Builds a legal filespec from component parts, adding punctuation as
necessary.
?fbuild path e \tcl macros tcl
results in
path=e:\tcl\macros.tcl
ISDIR -
Evaluates to true if the argument is a valid directory
?isdir \ writeln Yup, the root still exists.
FPARSE -
Breaks up the first argument into filespec components. The remaining
arguments are environment strings which are set to the component parts.
e.g.
fparse e:\tcl\macros.tcl disk path root ext
would result in
disk=e:
path=\tcl\
root=macros
ext=.tcl
If your not interested in a component, just use a period. If the component
is missing, the environment variable is deleted.
Here is a macro which applies a default extension to a path stored in
an environment string passed as the first arguement.
defext {<env var> <def ext>
?equ %1. . goto error
?fparse %1 . . . ext
?null ext eset %1=%1.%2
?clear ext
sample use
?pfi Enter\sfilespec:\s\s spec
defext spec txt
ERRL -
Is true if the return code from the last executed program is greater than
or equal to the argument.
example:
cc -c %* >logfile {compile c programs to objects
?^errl 1 return {if no error ok
writeln Compiler error!
abort {trash caller macro so he won't try to link
EXIST -
Is true if the specified file exists.
Here is a macro which makes sure an install is legal before doing it.
(a classic example of using the dot operator to make a built-in function
more intelligent)
install
?null %2 goto error1
?^exist %2 goto error2
.install %1 %2
return
:error1
writeln Install error: missing argument(s)
return
:error2
writeni Install error: file %2 doesn't exist.
writeln
TIME -
Sets an environment variable to the current date and time.
?time tm
writeln Test started at %tm%
test this and that
?time tm
writeln Test ended at %tm%
?clear tm
_______________________________________________________________________________
Zero Length Command Abbreviation
If TCL sees that the first token on a command line (considered to be the
"keyword") contains a period, then it assumes you have abbreviated the
actual command to zero characters. It then tries run a macro named "exttrap".
The macro must already be in memory. It won't be loaded automatically like
other macros. You have to do "loadm exttrap" at startup.
The entire line is passed to the "exttrap" macro with an extra argument
at the beginning. This argument is the extension from the first token,
including the period. Your macro can then decide what to do based on the
extension of the filespec. Here is an example (it happens to be my exttrap)
exttrap
eset ext=%1%<
?sim %ext% .? dir %1??
?sim %ext% .* dir %1
?sim %ext% .lnk lnk %1
?sim %ext% .c edt ..\c\%1
?sim %ext% .h edt ..\h\%1
?sim %ext% .asm edt ..\s\%1
?sim %ext% .inc edt ..\s\%1
?sim %ext% .mac edt ..\s\%1
?sim %ext% .sys edt \%1
?clear ext
return
I can then simply type
test.c
and the statement
edt ..\c\test.c
is executed.
_______________________________________________________________________________
Here are a zillion actual working macros from my macro files. The first
set is from my startup.tcl file and the rest are from my general macros.tcl
file. Sorry, no documentation but if you see something interesting yet
inexplicable, ask me about it in the notes file.
_______________________________________________________________________________
From my STARTUP.TCL
tclinit
tclstart
undef tclstart
tclstart
autoexec
undef autoexec
step2
undef step2
?exist g:\boottime goto msg2
?^exist \net.aex goto msg1
:gettime
writeln Getting date and time from BEORN.
gettime
?^exist \flags.aex goto err1
copy \flags.aex g:\boottime >>nul
goto end
:msg1
writeln Network appears to be not installed
yn Is\sthis\scorrect
?sim %yn% n goto gettime
yn Want\sto\sset\sdate\sand\stime
?sim %yn% n goto end
date
time
goto end
:msg2
?time tm
writeln Date and Time:\t%tm%
?clear tm
goto end
:err1
writeln \flags.aex is missing
:end
?clear yn
loadm exttrap
autoexec
eset comspec=e:\dos\command.com
?^isdir g:\ goto stay
copy \dos\command.com g: >>nul
eset comspec=g:\command.com
eset tmp=g:
:stay
eset include=f:\msc;..\h
eset lib=f:\msc;..\o
eset PATH=F:\TASKS;E:\DOS;F:\MSC;E:\POLY;E:\decnet;..\T
eset prompt=*$e[1m$p$g$e[m
copy ptp.cfg g: >>nul
?exist net.aex network
break on
cls
step2
writeln Welcome to MRDOS running TCL V1.1 - 37 users at 46%% CPU loading
set mf$ f:\batches\macros.tcl
set MF$ g:\macros.tcl
?exist MF$ writeln Macro file already on G:
?^exist MF$ writeln Moving macro file to drive G.
?^exist MF$ copy mf$ g: >>nul
mfile MF$
loadm install
hfile f:\batches\help.lng
writeln Setting startup logical names.
exec f:\batches\sets
exec b$setsmsc
writeln Setting startup installed names.
exec b$installs
cp netdrv
cls
_______________________________________________________________________________
From my MACROS.TCL
xmac
mfile %1%<
%*
undef %1
mfile MF$
tools
lib f:\msc\tctools%*;
apply
eset keyword=%1%<
:loop ?sim %1. . goto end
%keyword% %1%<
goto loop
:end
?clear keyword
ctest
writeln here is a comment {slisejf;lsiejf;asleifj
exttrap
eset ext=%1%<
?sim %ext% .? dir %1??
?sim %ext% .* dir %1
?sim %ext% .lnk lnk %1
?sim %ext% .c edt ..\c\%1
?sim %ext% .h edt ..\h\%1
?sim %ext% .asm edt ..\s\%1
?sim %ext% .inc edt ..\s\%1
?sim %ext% .mac edt ..\s\%1
?sim %ext% .sys edt \%1
?clear ext
return
defext
?fparse %1 d p r e
?sim %e%. . eset e=%2
?fbuild f d p r e
?clear d p r e
lnk
defext %1 .lnk
savdir
do
link @%f%
?clear %f%
restdir
mod?
search .. -name %1.[hcoe]* -ls
looper
:looper %*
goto looper
dif
?clear fcf
?sim %1. /b. eset fcf=%1<
eset f1=%1
eset f2=%2
?null f1 pfi File\sCompare\sfirst? f1
?null f1 return
?null f2 pfi File\sCompare\ssecond? f2
?fparse %f1% d1 p1 r1 e1
?clear d2 p2 r2 e2
?^null f2 ?fparse %f2% d2 p2 r2 e2
?null f2 eset r2=%r1%
?^null r2 goto chke
yn Do\syou\smean\s'%r1%.bak'
?sim %yn% y eset r2=%r1%
?sim %yn% y goto doit
:chke ?^null e2 goto doit
?^sim %r1% %r2% eset e3=%e1%
?sim %r1% %r2% eset e3=.bak
?sim %f1%%d1%. . eset e3=.bak
yn Do\syou\smean\s'%r2%%e3%'
?sim %yn% n abort
?sim %yn% y eset e2=%e3%
:doit ?fbuild f1 d1 p1 r1 e1
?fbuild f2 d2 p2 r2 e2
writeni fc %fcf% %f1% %f2%
fc %fcf% %f1% %f2%
yn
yesno %1 yn
yesno
?sim %2. . goto error
:top write %1? [y/n]\s\s
?^input ttyn goto top
?first %ttyn% tyn
?clear ttyn
?^sim %tyn% y ?^sim %tyn% n goto top
eset %2=%tyn%
?clear tyn
return
:error writeln \nYESNO Error: missing argument(s)
abort
mpfi
?sim %2. . goto error
goto top
:loop writeln Input is mandatory - try again
:top write %1\s\s
?^input %2 goto loop
return
:error writeln \nMPFI Error: missing argument(s)
pfi
?sim %2. . goto error
write %1\s\s
?input %2
return
:error writeln \nPFI Error: missing argument(s)
intest
:top mpfi Enter\ssome\stext: text
:opt pfi Enter\soptional\stext:\s\s opt
?null opt goto next
writeln optional text is "%opt%"
:next write You typed "
writeni %text%
writeln "
:merge yn Merge them
?sim %yn% n goto del
eset tmp=%opt%%text%
eset text=%tmp%
?clear tmp
writeln Merged string is '%text%'
:del yn Delete\sit
?sim %yn% y ?clear text
?^sim %yn% y goto opt
:exit ?clear opt
yn Run\sthrough\sit\sagain
?sim %yn% y goto top
?clear yn
return
maktcl
?sim %1. latest. goto latest
?sim %1. link. goto link
cls
?clear args
:loop eset f=%1%<
?null f goto ready
?fparse %f% d p r e
?null e eset e=.c
?fbuild f d p r e
?^null args eset args=%args% %f%
?null args eset args=%f%
goto loop
:ready
?clear f d p r e
?^null args co %args%
?clear args
yn Continue
?sim %yn% y goto link
?clear yn
abort
:link
?clear yn
do
link @tcl.lnk
metd tclnew
exemod \tasks\tclnew.exe
writeln
write Enter new max:
?^input max goto end
exemod \tasks\tclnew.exe /max %max%
:end
?clear max
e:
dr
writeln Ready to EXIT.
return
:latest
?^exist f:\tasks\tclnew.exe goto nofile
del f:\tasks\tcl.exe
ren f:\tasks\tclnew.exe tcl.exe
writeln done
return
:nofile
writeln There is no new version of TCL.
return
isdir
?sim %1. . goto err
?^isdir %1 goto no
writeln yes
return
:no
writeln no
return
:err writeln ISDIR missing argument
abort
install
?exist %2 .install %1 %2
?^exist %2 writeni Install Error: File '%2' isn't visible
time?
?time time
writeni Current Date and Time - %time%
?clear time
ENTD
e:
ntd %*
f:
NTD
savdir
cd \decnet\decnet
%*
restdir
AS
set ra as %*
savdir
ds
:loop
?sim %1. . goto end
eset f=%1%<
?clear r e
?fparse %f% . . r e
?null e eset f=%f%.asm
writeni masm %f%/mx,..\o\;
masm %f%/mx,..\o\;
goto loop
:end
?clear r e
restdir
SYM
savdir
dt
set debug symdeb %1.sym %1.exe
mapsym %1%<
?^sim %2. . goto next
yn Run\ssymdeb
?sim %yn% n goto next
debug
:next restdir
?clear yn
%*
edoc
set efile f:\doc\%1.doc
e
DOC
fv f:\doc\%1.doc
NT
savdir
cd \decnet\decnet
ntest
restdir
BLDNET
savdir
do
link @dndcprb.lnk
restdir
BEORN
sethost beorn
GETTIME
nettime beorn//
MOVE
search %1 -mv %2
TESTSYS
copy \testsys \config.sys
TRUESYS
copy \truesys \config.sys
TCLOFF
ren \tcl.aex notcl.aex
TCLON
ren \notcl.aex tcl.aex
EMK
set efile ..\c\%1.mak
e
MAK
savdir
cd ..\c
make /f %1.mak
restdir
VDISK
ndu ope dri %1 nod beorn ndis blxc:netdrv.%2
VDISKRO
ndu ope dri %1 nod beorn ndis blxc:netdrv.%2 acc ro
VDCLOSE
ndu clo dri h
CERR
eset logerr=%%>..\c\cerrlog
eset showlog=type ..\c\cerrlog
NOCERR
eset logerr=
eset showlog=
DLOG
del ..\c\cerrlog
PATH
eset path=%*
ATT
ntest attach %1%<
%*
CON
ntest connect %*
DET
ntest detach %1%<
%*
LOG
ntest log
%*
CHK
ntest chk %*
NETOFF
ntest set lin sta off
ntest log
NETON
ntest set lin sta on
ntest log
GREP
set grepword %1%<
search %* | map -x find grepword %%s | command
set grepword
SPR
shortpr <%1 >prn
tof
EXEC
tclaux tomacro %1 g:$macro$
?errl 1 abort
mfile g:$macro$
loadm $macro$
del g:$macro$
mfile MF$
$macro$
undef $macro$
LEARN
tclaux tomacro %1 g:$macro$ %1
mfile g:$macro$
loadm %1
del g:$macro$
mfile MF$
NETH
copy \netdrv\h\*.h g: >>nul
chkdsk g:
MOVH
copy ..\h\*.h g: >>nul
chkdsk g:
PRIN1
type %1 >prn
tof
DW
dir %1/w%<
%*
D
dir %1%<
%*
C
set rc c %*
savdir
cd ..\c
cc Csw0 %* %logerr%
%showlog%
restdir
?^errl 1 return
writeln Abort due to compile error.
abort
CO
c -c %*
CA
co /Fa %1
MET
copy ..\t\%1.exe f:\tasks >>nul
METD
?exist ..\t\%1.exe goto doit
writeln
writeni METD error - %1.exe not found
writeln
abort
:doit
copy ..\t\%1.exe f:\tasks >>nul
del ..\t\%1.exe
PE
prin1 efile
EC
set efile ..\c\%1.c
e
E
writeni editing efile
edt efile
EM
set efile ..\s\%1.mac
e
EA
set efile ..\s\%1.asm
e
ES
set efile ..\s\%1.s
e
EH
set efile ..\h\%1.h
e
EMAC
?sim %1. s. goto startup
ptp mf$
copy mf$ MF$ >>nul
?exist b$macros.bak del b$macros.bak
return
:startup edt f:\batches\startup.tcl
?exist b$startup.bak del b$startup.bak
DC
cd ..\c%<
%*
DS
cd ..\s%<
%*
DH
cd ..\h%<
%*
DO
cd ..\o%<
%*
DT
cd ..\t%<
%*
DD
cd ..\d%<
%*
UP
cd ..
%*
CPS
cd \%1\%2%<
%*
CP
cd \%1\c%<
%*
DR
cd \%<
%*
DB
cd f:\batches
%*
PURGE
whereis *.bak|map -x del %%s|command
X
dir %1*.*%<
%*
DX
del %1*.*%<
%*
OLORIN
savdir
cd \poly
ren olorin.trm $$$dflt.trm
trm
ren $$$dflt.trm olorin.trm
restdir
EAUTO
edt \autoexec.bat
ECONF
edt \config.sys
DEB
del *.bak
%*
WH
whereis %1%< %*
ZAP
del %1\*.*
rmdir %1
GETH
copy ..\h\%1.h g: >>nul
chkdsk g:
EHELP
edt f:\batches\help.lng
SIDIT
savdir
dt
sid sidfile sidfile
restdir
RMPROJ
search \%1 -name *.* -rm -rmdir
MKPROJ
mkdir \%1
mkdir \%1\c
mkdir \%1\s
mkdir \%1\o
mkdir \%1\h
mkdir \%1\t
mkdir \%1\d
GET
nft copy beorn::%1
CTF
copy %1 a: >>nul
CFF
copy a:%1 >>nul