- Tcl - Regular Expressions
- Tcl - Built-in Functions
- Tcl - Error Handling
- Tcl - File I/O
- Tcl - Namespaces
- Tcl - Packages
- Tcl - Procedures
- Tcl - Dictionary
- Tcl - Lists
- Tcl - Strings
- Tcl - Arrays
- Tcl - Loops
- Tcl - Decisions
- Tcl - Operators
- Tcl - Variables
- Tcl - Data Types
- Tcl - Commands
- Tcl - Basic Syntax
- Tcl - Special Variables
- Tcl - Environment Setup
- Tcl - Overview
- Tcl - Home
Tk Tutorial
- Tk - Geometry Manager
- Tk - Windows Manager
- Tk - Events
- Tk - Images
- Tk - Fonts
- Tk - Mega Widgets
- Tk - Canvas Widgets
- Tk - Selection Widgets
- Tk - Layout Widgets
- Tk - Basic Widgets
- Tk - Widgets Overview
- Tk - Special Variables
- Tk - Environment
- Tk - Overview
Tcl/Tk Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Tcl - Special Variables
In Tcl, we classify some of the variables as special variables and they have a predefined usage/functionapty. The pst of specials variables is psted below.
Sr.No. | Special Variable & Description |
---|---|
1 | argc Refers to a number of command-pne arguments. |
2 | argv Refers to the pst containing the command-pne arguments. |
3 | argv0 Refers to the file name of the file being interpreted or the name by which we invoke the script. |
4 | env Used for representing the array of elements that are environmental variables. |
5 | errorCode Provides the error code for last Tcl error. |
6 | errorInfo Provides the stack trace for last Tcl error. |
7 | tcl_interactive Used to switch between interactive and non-interactive modes by setting this to 1 and 0 respectively. |
8 | tcl_pbrary Used for setting the location of standard Tcl pbraries. |
9 | tcl_pkgPath Provides the pst of directories where packages are generally installed. |
10 | tcl_patchLevel Refers to the current patch level of the Tcl interpreter. |
11 | tcl_platform Used for representing the array of elements with objects including byteOrder, machine, osVersion, platform, and os. |
12 | tcl_precision Refers to the precision i.e. number of digits to retain when converting to floating-point numbers to strings. The default value is 12. |
13 | tcl_prompt1 Refers to the primary prompt. |
14 | tcl_prompt2 Refers to the secondary prompt with invapd commands. |
15 | tcl_rcFileName Provides the user specific startup file. |
16 | tcl_traceCompile Used for controlpng the tracing of bytecode compilation. Use 0 for no output, 1 for summary, and 2 for detailed. |
17 | tcl_traceExec Used for controlpng the tracing of bytecode execution. Use 0 for no output, 1 for summary, and 2 for detailed. |
18 | tcl_version Returns the current version of the Tcl interpreter. |
The above special variables have their special meanings for the Tcl interpreter.
Examples for using Tcl special variables
Let s see some examples for special variables.
Tcl version
#!/usr/bin/tclsh puts $tcl_version
When you run the program, you will get a similar output as shown below −
8.6
Tcl Environment Path
#!/usr/bin/tclsh puts $env(PATH)
When you run the program, you will get a similar output as shown below −
/home/cg/root/GNUstep/Tools:/usr/GNUstep/Local/Tools:/usr/GNUstep/ System/Tools:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/webmaster/.local/bin:/ home/webmaster/bin:/usr/local/scriba/bin:/usr/local/smlnj/ bin:/usr/local/bin/std:/usr/local/bin/extra:/usr/local/fantom/bin:/usr/ local/dart/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/opt/mono/ bin:/opt/mono/pb/mono/4.5:/usr/local/bin:.:/usr/pbexec/sdcc:/usr/local/ icon-v950/bin:/usr/local/mozart/bin:/opt/Pawn/bin:/opt/jdk1.7.0_75/bin:/ opt/jdk1.7.0_75/jre/bin:/opt/pash/Source/PashConsole/bin/Debug/
Tcl Package Path
#!/usr/bin/tclsh puts $tcl_pkgPath
When you run the program, you will get a similar output as shown below −
/usr/pb64/tcl8.6 /usr/share/tcl8.6 /usr/pb64/tk8.6 /usr/share/tk8.6
Tcl Library
#!/usr/bin/tclsh puts $tcl_pbrary
When you run the program, you will get a similar output as shown below −
/usr/share/tcl8.6
Tcl Patch Level
#!/usr/bin/tclsh puts $tcl_patchLevel
When you run the program, you will get a similar output as shown below −
8.6.6
Tcl Precision
#!/usr/bin/tclsh puts $tcl_precision
When you run the program, you will get a similar output as shown below −
0
Tcl Startup File
#!/usr/bin/tclsh puts $tcl_rcFileName
When you run the program, you will get a similar output as shown below −
~/.tclshrcAdvertisements