Skip to main content

TCC Aliases

Much of the power of TCC comes together in aliases, which give you the ability to create your own commands. An alias is a name that you select for a command or group of commands. Simple aliases substitute a new name for an existing command. More complex aliases can redefine the default settings of internal or external commands, operate as very fast in-memory batch files, and perform commands based on the results of other commands.

TCC also supports Directory Aliases, a shorthand way of specifying pathnames, and keystroke aliases, which lets you assign one or more commands to a single keystroke.

You can create either a local alias list that is only visible to the current TCC session, or a global alias list that is shared among all TCC sessions.

The ALIAS command lets you create new command names or redefine internal commands. It also lets you assign one or more commands to a single keystroke. An alias is often used to execute a complex series of commands with a few keystrokes or to create "in memory batch files" that run much faster than disk-based batch files.

TCC Variables

Batch files can use environment variables, internal variables, variable functions, or user-defined functions. You can use these variables and functions to determine system status (e.g., the CPU type), resource levels (e.g., the amount of free disk space), file information (e.g., the TCC date and time a file was last modified), and other information (e.g., the current date and time). You can also perform arithmetic operations (including date and time arithmetic), manipulate strings and substrings, extract parts of a filename, and read and write files.

The SET command in TCC allows you to define variable types. If you try to set the variable to an incompatible type, SET will return an error. The supported types are:

int (or 1) The variable can only contain 0-9
dec (or 2) The variable can only contain 0-9, the decimal character, and the thousands separator
hex (or 3) The variable can only contain 0-9 and A-F
bool (or 4) The variable can only contain 0 or 1
alpha (or 5) The variable can only contain A-Z and a-z
alnum (or 6) The variable can only contain A-Z, a-z, and 0-9
regex (or 7) The variable must match the specified regular expression

TCC Internal Variables

Internal variables are special variables built into TCC to provide information about your system. They are not stored in the environment, but can be accessed as if they were environment variables in interactive commands, aliases, and batch files.

The values of these variables are stored internally in TCC, and cannot be changed with the SET, UNSET, ESET or any other command. The DEFINED status test will always fail, too. You can override any of these variables by defining a new environment variable with the same name. The internal variable can be made available again by unsetting the identically name environment variable. The names of ALL internal variables (except the pseudovariables errorlevel, ?, and ??) begin with an underscore character to make it easier to distinguish them and to avoid accidentally overriding them.

TCC Variable Functions

Variable functions are very similar to internal variables, but they take one or more parameters (which can be environment variables or even other variable functions).

Variable functions are useful at the command prompt as well as in aliases and batch files to check on available system resources, manipulate strings and numbers, and work with files and filenames.

User Defined Variable Functions

FUNCTION allows you to create or display user-defined variable functions that can be used anywhere Variable Functions can be used. User-defined functions are powerful alternatives to subroutines.