92,99 €
PROGRAMMING AND GUI FUNDAMENTALS Discover the foundations of TCL programming and GUI development Programming and GUI Fundamentals: Tcl-Tk for Electronic Design Automation (EDA), delivers a comprehensive exploration of the major design challenges and potential present in application and tool development with Tcl-Tk. Accessibly written and easy-to-understand, the book can be used by students at a variety of levels, as well as researchers and working professionals. The authors present the fundamental concepts of Tcl programming and graphic user interface (GUI) development using images, and photographs, assisting with concept understanding and retention. They describe real-time system designs and offer students and designers the opportunity to learn about critical concepts in scripting and GUI development. Readers will learn to design their own GUI, place and package widgets on the GUI, and allow EDA professionals, chip designers and students to code and design in TCL-TK. They will also benefit from: * A thorough introduction to scripting languages and wish interpreters, including their fundamental concepts, TCL tips and tricks, and command, variable, and procedure examples * Comprehensive explorations of the TCL data structure, including datatypes, strings and commands, lists and commands, and arrays and commands * Practical discussions of TCL control flow, including conditional commands, multi-condition commands, and loop commands * In-depth examinations of file input/output processing, including TCL file read-write, open and close commands, gets, and puts. Perfect for undergraduate and graduate students studying programming or computer science, as well as professionals working on electronic design automation and chip design, Programming and GUI Fundamentals: Tcl-Tk for Electronic Design Automation (EDA) is also an indispensable resource for programming professionals seeking to upskill.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 261
Veröffentlichungsjahr: 2022
Cover
Title Page
Copyright
About the Authors
1 Introduction
1.1 Features of Tcl
1.2 Special Variable
1.3 Tcl First Program
1.4 Tcl Identifiers
1.5 Applications of Tcl
References
2 Basic Commands
2.1 Introduction
2.2 Set Command
2.3 Variable Substitution
2.4 Grouping
2.5 Command Substitution
2.6 Math Expressions
2.7 Backslash Substitution (
\&
)
2.8 Tcl Operator
2.9 Procedure
2.10 Eval Commands
2.11 Solved Questions
2.12 Review Questions
2.13 MCQs Based on Tcl Basics
References
2.A Appendix I (Built‐in math functions)
2.B Appendix II (Tcl Backslash sequence)
3 Program Flow Control
3.1 If–Else Command
3.2 Switch‐Case Command
3.3 Loop Command
3.4 Continue and Break
3.5 Catch and Error
3.6 Solved Problems
3.7 Practice Questions
3.8 MCQs
References
4 Tcl Data Structure
4.1 String and Matching Command
4.2 Lists and their Commands
4.3 Arrays and their Commands
References
5 Tcl Object‐Oriented Programming
5.1 Class
5.2 Creation of a Class
5.3 Define a Member in a Class
5.4 Define Method
5.5 Constructor and Destructor
5.6 Destroying of Class
5.7 Invoking Method
5.8 Registering Method for Callback
References
6 File Processing
6.1 Introduction
6.2 Tcl File Command
6.3 Tcl File In‐built Commands
6.4 Solved Questions
6.5 Review Questions
6.6 MCQs based on Tcl File Processing
References
7 Toolkit Widgets
7.1 Features of Tk Widgets
7.2 Geometry Manager
7.3 Widget Naming
7.4 Widget Dimension
7.5 Widget Configuration
7.6 Widget Programming
7.7 Solved Problems
7.8 Unsolved Problems
7.9 MCQs on Tk Widgets
References
8 Binding Commands and Other Widgets
8.1 Class and Widget Binding
8.2 Widget Characteristic Commands
8.3 Menubar‐Menu‐Menubutton
8.4 Tearoff Command
8.5 Listbox Widget
8.6 Place Manager
8.7 Solved Problems
8.8 MCQs on Bind, Menu, and Place Manager
References
9 Canvas Widgets and Tk Commands
9.1 Canvas Coordinate
9.2 Drawing over Canvas
9.3 Event Binding of Canvas Object
9.4 Create a Movable Object
9.5 Tk built‐in Command
9.6 Solved Problems
9.7 Review Problem
9.8 MCQs of Canvas
9.A Appendix A
References
10 Tcl‐Tk for EDA Tool
10.1 Accessing Vivado Tool via Tcl Script
10.2 Sourcing the Tcl Script with Vivado
10.3 Implementing Counter Program with Vivado Tcl Console
10.4 Advantage of Vivado in Tcl Mode
Reference
10.A Appendix
Index
End User License Agreement
Chapter 1
Table 1.1 Programming and scripting language comparison.
Chapter 2
Table 2.1 Arithmetic operator.
Table 2.2 Relational operator.
Table 2.3 Logical operator.
Table 2.4 Bitwise operator.
Table 2.5 Shift operator.
Table 2.6 Operator precedence order.
Chapter 4
Table 4.1 String‐based command.
Table 4.2 Format specifier.
Table 4.3 List‐based command.
Table 4.4 Arrray command in Tcl.
Chapter 6
Table 6.1 Access mode of Tcl file.
Table 6.2 Tcl file in‐built command.
Chapter 7
Table 7.1 Tk widget command.
Table 7.2 Widget configuration.
Table 7.3 Scale commands.
Chapter 8
Table 8.1 List of event generation.
Table 8.2 Attributes to menu.
Table 8.3 Attributes to menubutton.
Chapter 9
Table 9.1 Attributes to the canvas.
Table A.1
Tk
in‐built command.
Chapter 10
Table 10.1 Command to access Vivado Tool.
Chapter 1
Figure 1.1 Command‐line interpreter.
Figure 1.2 Wish interpreter.
Figure 1.3 Tkcon interpreter.
Figure 1.4 Tcl special variable.
Figure 1.5 Tcl simple program.
Chapter 2
Figure 2.1 Tclsh screen.
Figure 2.2 Wish screen.
Figure 2.3 The
puts
command in Tcl.
Figure 2.4 The
puts
command with (\) sequence.
Figure 2.5 Variable declarations with the
set
command.
Figure 2.6 Variable substitution.
Figure 2.7 Substitution with grouping.
Figure 2.8 Command substitution.
Figure 2.9 Nesting of commands.
Figure 2.10 Math expressions with the
expr
command.
Figure 2.11 Disable substitution.
Figure 2.12 Arithmetic operator.
Figure 2.13 Relational operator.
Figure 2.14 Logical operator.
Figure 2.15 Bitwise operator.
Figure 2.16 Ternary operator.
Figure 2.17 Shift left and shift right.
Figure 2.18 Addition with the procedure.
Figure 2.19 Using
proc
with default variable.
Figure 2.20 The
eval
command.
Figure 2.21 Temperature conversion with
proc
.
Figure 2.22 Random number generation with
rand()
function.
Figure 2.23 Using
proc
to find the maximum of two numbers.
Figure 2.24 Factorial computation using
proc
.
Chapter 3
Figure 3.1
If–else
condition flowchart.
Figure 3.2
If–elseif–else
condition flowchart.
Figure 3.3
Switch
case flowchart.
Figure 3.4
While
loop flowchart.
Figure 3.5 Flowchart of
for
loop.
Figure 3.6
Foreach
command flowchart.
Chapter 4
Figure 4.1 String declaration.
Figure 4.2 String basic command.
Figure 4.3 String trim.
Figure 4.4 String case.
Figure 4.5 String compare.
Figure 4.6 String append.
Figure 4.7 Format command example.
Figure 4.8 Format command with precision.
Figure 4.9 Decimal to other formats.
Figure 4.10 Octal to other formats.
Figure 4.11 Binary to other formats.
Figure 4.12 Hexadecimal to other formats.
Figure 4.13 Scan command example.
Figure 4.14 Clock seconds example.
Figure 4.15 Time representation with clock format.
Figure 4.16 Clock format with predefined template.
Figure 4.17 Clock format to display system time.
Figure 4.18 Clock scan.
Figure 4.19 Clock add.
Figure 4.20 List declaration.
Figure 4.21 List created in Tcl console.
Figure 4.22 Element‐based list command.
Figure 4.23 String as an element of the list.
Figure 4.24
linsert
example.
Figure 4.25
lreplace
example.
Figure 4.26
lsearch
example.
Figure 4.27
lassign
example.
Figure 4.28
lsort
example.
Figure 4.29 Split and join example.
Figure 4.30 Array initialization by array command.
Figure 4.31 Array initialization by setting elements.
Figure 4.32 Array index as an alphanumeric character.
Chapter 5
Figure 5.1 Destroying of class.
Chapter 6
Figure 6.1 Tcl script to open a file with extension.
Figure 6.2 Result of Figure 6.1.
Figure 6.3 Tcl script to close a file.
Figure 6.4 Tcl script to write with the
puts
command.
Figure 6.5 Tcl script to write multiple statements with the
puts
command.
Figure 6.6 File available in the directory.
Figure 6.7 Tcl script for a single statement.
Figure 6.8 © Tcl script for multiple statements.
Figure 6.9 Tcl script to read the file in a loop.
Figure 6.10 Tcl script for the
read
command
Figure 6.11 Previous content in the file.
Figure 6.12 Result after appending.
Figure 6.13 File‐based in‐built commands with examples.
Figure 6.14 Initial content in a file.
Figure 6.15 Execution result of file access by the
list
command.
Figure 6.16 Writing with the
puts
command.
Figure 6.17 Reading with the
gets
command.
Figure 6.18 Earlier content written in the file.
Figure 6.19 Execution result of the
read
inside the loop.
Figure 6.20 Integer already written in the file.
Figure 6.21 Execution result of
read
command.
Figure 6.22 Content of file one.csv to be read.
Figure 6.23 Content written in two.csv.
Figure 6.24 Random number written in the file.
Figure 6.25 Initial measurement of experiments.
Figure 6.26 Result of the script.
Chapter 7
Figure 7.1 Button widget.
Figure 7.2 Multiple widgets on screen.
Figure 7.3 Button with the
puts
command.
Figure 7.4 Button with the
exit
command.
Figure 7.5 Button and different attributes.
Figure 7.6 Label widget.
Figure 7.7 Label with different attributes.
Figure 7.8 Button with config.
Figure 7.9 Label with config.
Figure 7.10 Sum in a label.
Figure 7.11 Entry for user input.
Figure 7.12 Entry with textvariable.
Figure 7.13 Entry space with a hidden character.
Figure 7.14 Frame widget.
Figure 7.15 Buttons in horizontal and vertical arrangements.
Figure 7.16 Scale orientation.
Figure 7.17 Slider on a scale.
Figure 7.18 Scale with procedure.
Figure 7.19 Message text on multiple lines.
Figure 7.20 Product with a spinbox widget.
Figure 7.21 GUI for random number generation.
Figure 7.22 Scale with procedure.
Figure 7.23 GUI of the half adder.
Figure 7.24 GUI of the full adder.
Figure 7.25 GUI of a calculator.
Figure 7.26 GUI of a power calculation.
Figure 7.27 Message justified with the aspect ratio.
Chapter 8
Figure 8.1 Before event.
Figure 8.2 After event.
Figure 8.3 Before event.
Figure 8.4 After event.
Figure 8.5 Before event.
Figure 8.6 After event.
Figure 8.7 Before event.
Figure 8.8 After event.
Figure 8.9 Horizontal scale scrollbar movement maps of keysym.
Figure 8.10 Button‐label on Frame‐1.
Figure 8.11 Button‐label on Frame‐2.
Figure 8.12 Remove button from Frame‐1.
Figure 8.13 Remove label from Frame‐2.
Figure 8.14 Remove Frame‐1.
Figure 8.15 Arrange a button on the right side.
Figure 8.16 Horizontal stack.
Figure 8.17 Vertical stack.
Figure 8.18 Remove button from Frame‐1.
Figure 8.19 Widget showing cavity on frame.
Figure 8.20 Widget with
–fill
command.
Figure 8.21 Widget with
–expand
command.
Figure 8.22 Button with ipad.
Figure 8.23 Direction with anchoring.
Figure 8.24 Anchoring of label.
Figure 8.25 Creation of menu for menubutton.
Figure 8.26 Adding entries to menu.
Figure 8.27 Menu with separator.
Figure 8.28 Tcl command associated with menu entry.
Figure 8.29 Creation of submenu.
Figure 8.30 Command link to menu and submenu.
Figure 8.31 Configuring menu entries.
Figure 8.32 Creation of pop‐up menu.
Figure 8.33 Creation of listbox.
Figure 8.34 Listbox with select mode.
Figure 8.35 Relation position range.
Figure 8.36 Absolute positioning with place manager.
Figure 8.37 Relative positioning with place manager.
Figure 8.38 Before event.
Figure 8.39 Event on binary.
Figure 8.40 Event on octal.
Figure 8.41 Event on hexadecimal.
Figure 8.42 Calculator before input.
Figure 8.43 Calculator with the result.
Figure 8.44 Creation of button with
for
loop.
Figure 8.45 GUI of the calculator with scale input.
Figure 8.46 Two menubuttons.
Figure 8.47 Menu of menubutton‐1.
Figure 8.48 Menu of menubutton‐2.
Figure 8.49 Submenu.
Figure 8.50 Place manager with relation position.
Chapter 9
Figure 9.1 Canvas with background color.
Figure 9.2 Arc on the canvas.
Figure 9.3 Line on the canvas.
Figure 9.4 Rectangle on the canvas.
Figure 9.5 Polygon on the canvas.
Figure 9.6 Oval on the canvas.
Figure 9.7 Text on the canvas.
Figure 9.8 Bitmap.
Figure 9.9 Bitmap on the canvas.
Figure 9.10 Image in the directory.
Figure 9.11 Image on the canvas.
Figure 9.12 Image in the directory.
Figure 9.13 Image on the canvas.
Figure 9.14 Image dimension adjustment.
Figure 9.15 Image dimension for each image.
Figure 9.16 Objects on the canvas.
Figure 9.17 Circle using arcs.
Figure 9.18 Bounded text widget.
Figure 9.19 Bounded text widget at different locations on the canvas.
Figure 9.20 Movable oval on the canvas
Figure 9.21 Movable oval and line on the canvas.
Figure 9.22 Movable image on the canvas.
Figure 9.23 Object on the canvas via
eval
command.
Figure 9.24 GUI before event.
Figure 9.25 GUI during first event.
Figure 9.26 GUI during second event.
Figure 9.27 GUI after both events.
Figure 9.28 Before event.
Figure 9.29 Pop‐up dialog box.
Figure 9.30 After event.
Figure 9.31 Before event.
Figure 9.32 Pop‐up dialog box to select the file.
Figure 9.33 After event.
Figure 9.34 Message box before response.
Figure 9.35 Message box after selecting No.
Figure 9.36 Sine wave.
Figure 9.37 Square wave.
Figure 9.38 Symbolic library interface.
Figure 9.39 Function on the canvas.
Figure 9.40 Canvas clear function
Figure 9.41 Progressbar before event.
Figure 9.42 Progressbar after event.
Chapter 10
Figure 10.1 Homepage of Vivado Design Suite.
Figure 10.2 Vivado interface after creating project.
Figure 10.3 Adding FA module.
Figure 10.4 Adding stimulus file.
Figure 10.5 Adding constraint file.
Figure 10.6 Synthesize project summary.
Figure 10.7 FPGA package view.
Figure 10.8 Testbench waveform.
Figure 10.9 Power report.
Figure 10.10 Timing report.
Figure 10.11 Utilization report.
Figure 10.12 Datasheet report.
Figure 10.13 Source and constraint file of full subtractor.
Figure 10.14 Sourcing a .tcl script.
Figure 10.15 Simulation waveform of FS.
Figure 10.16 Utilization reports of FS.
Figure 10.17 Timing report of FS.
Figure 10.18 Power report of FS.
Figure 10.19 Datasheet report of FS.
Figure 10.20 Source and constraint file of counter.
Figure 10.21 Sourcing of counter.tcl.
Figure 10.22 Simulation waveform of the counter.
Figure 10.23 Utilization report of counter.
Figure 10.24 Power report of counter.
Figure 10.25 Timing report of counter.
Figure 10.26 Datasheet report of counter.
Cover
Table of Contents
Title Page
Copyright
About the Authors
Begin Reading
Index
End User License Agreement
ii
iii
iv
xi
xii
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
185
186
187
188
189
190
191
192
194
196
197
198
199
206
200
201
202
203
204
205
207
208
209
211
212
213
IEEE Press
445 Hoes Lane Piscataway, NJ 08854
IEEE Press Editorial Board
Sarah Spurgeon,
Editor in Chief
Jón Atli Benediktsson
Andreas Molisch
Diomidis Spinellis
Anjan Bose
Saeid Nahavandi
Ahmet Murat Tekalp
Adam Drobot
Jeffrey Reed
Peter (Yong) Lia
Thomas Robertazzi
Suman Lata TripathiLovely Professional UniversityPhagwara, India
Abhishek KumarLovely Professional UniversityPhagwara, India
Jyotirmoy PathakLovely Professional UniversityPhagwara, India
Copyright © 2023 by The Institute of Electrical and Electronics Engineers, Inc. All rights reserved.
Published by John Wiley & Sons, Inc., Hoboken, New Jersey.Published simultaneously in Canada.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per‐copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750‐8400, fax (978) 750‐4470, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748‐6011, fax (201) 748‐6008, or online at http://www.wiley.com/go/permission.
Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Further, readers should be aware that websites listed in this work may have changed or disappeared between when this work was written and when it is read. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.
For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762‐2974, outside the United States at (317) 572‐3993 or fax (317) 572‐4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic formats. For more information about Wiley products, visit our web site at www.wiley.com.
Library of Congress Cataloging‐in‐Publication Data applied for:
Hardback: 9781119837411
Cover Design: WileyCover Image: © whiteMocca/Shutterstock
Dr. Suman Lata Tripathi received her Ph.D. in the area of microelectronics and VLSI from MNNIT, Allahabad. She received her M.Tech in Electronics Engineering from UP Technical University, Lucknow, and her B.Tech in Electrical Engineering from Purvanchal University, Jaunpur. She is a Professor at Lovely Professional University and has more than seventeen years of experience in academics. She has published more than 74 research papers in refereed journals and conferences. She has organized several workshops, summer internships, and expert lectures for students. She has worked as a session chair, conference steering committee member, editorial board member, and reviewer in international/national IEEE journals and conferences. She has received the “Research Excellence Award” in 2019 and “Research Appreciation Award” in 2020, 2021 at Lovely Professional University, India. She received the best paper award at IEEE ICICS‐2018. She has published the edited books Recent Advancement in Electronic Devices, Circuit, and Materials; Advanced VLSI Design and Testability Issues; and Electronic DevicesandCircuit Design Challenges for IoT Application. She is also an editor of the book series on Green Energy: Fundamentals, Concepts, and Applications and Design and Development of Energy Efficient Systems, which are yet to be published. She is currently working on an accepted book proposal specifically on Electronic Device and Circuits Design Challenges to Implement Biomedical Applications. She is working as a series editor for a title,Smart Engineering Systems.
Her area of expertise includes microelectronics device modeling and characterization, low power VLSI circuit design, VLSI design of testing, advanced FET design for IoT, embedded system design, biomedical applications, etc.
Mr. Jyotirmoy Pathak has completed his post graduation in VLSI Design and graduation in Electronics and Communication Engineering from Anna University, India. He holds more than 10 research papers in a refereed journal. He holds 9 patents and 1 copyright. He has been the reviewer of many journals such as the IETE Journal of Research etc. He has also played the role of session chair for many international conferences.
His area of expertise includes VLSI signal processing, hardware security, FPGA prototype development, and low power ASIC design.
Dr. Abhishek Kumar obtained his Ph.D. in the area of VLSI Design for Low Power and Secured Architecture from Lovely Professional University, India. He received his M.Tech in Electronics Engineering from the University of Mumbai, India, and graduated from The Institution of Engineers (India). He has been an Associate Professor at Lovely Professional University for 11 years. He has published more than 35 research papers in refereed journals and conferences. He has organized workshops, summer internships, and expert lectures for students. He has worked as a session chair, conference steering committee member, editorial board member, and reviewer in international/national journals and conferences. He has published the book Intelligent Green Technologies for Sustainable Smart Cities with Wiley‐Scrivener and another book Machine Learning Technique with VLSI is in production with Wiley‐Scrivener.
His area of expertise includes VLSI design, low power architecture, memory design, data converters, ASIC‐SoC, cryptology, and side channel attacks.
Language is a structured system of communication used by humans. When a human wishes to communicate with a computer system, a programming language is required. A programming language is able to convert a set of instructions, known as the source code, to perform a specific task. There are a number of common programming languages, such as C, C++, and JAVA. Each programming language requires a specific compiler, which is able to translate the source code into machine code. There are also other mechanisms to produce machine code that are interpreter‐based, and these use step‐by‐step executors of the source code. A language can be implemented with either a compiler or interpreter. A combination of both platforms is possible too where the compiler generates the machine code and then passes it to the interpreter for execution [1].
Tcl stands for Tool Command Language. It is an interpreter‐based scripting language, designed to be easy to embed into the application. A scripting language is a programming language that automates the execution of tasks. Scripts are written for the run time execution and are interpreted rather than compiled. Some popular scripting languages are Python, Ruby, Bash, Node Js, and Perl. Scripting languages are required in web applications, system administration, gaming, and plugin development for an existing system. Scripting languages are preferred owing to the (i) ease of learning, (ii) fast editing, (iii) interactivity, and (iv) functionality.
The shell script is a set of instructions in the specific programming language to be run by the UNIX shell, a command‐line interpreter. Tcl (pronounced as tickle) is high‐level, interpreted, dynamic programming. Tcl is very similar to the UNIX shell languages, namely Bounce, C, Korn, and Perl, and therefore offers a wide range of programmability [2]. Tcl supports a wide range of programming paradigms, like object‐oriented programming, and the imperative and functional procedural styles offer the ability for applications to communicate with each other. It is possible to associate Tcl with the toolkit (Tk) used for building a graphical user interface (GUI). Tk is a cross‐platform, which offers a wide range of widget libraries that can also be associated with other programming languages.
Tcl and the X‐window toolkit were developed by Prof. John Ousterhout of U.C. Berkeley to solve the difficulty associated with a programming language. It was initially developed for UNIX, then ported to Windows, MAC, DOS, and QS/2. Its ability to integrate a Tcl interpreter with existing applications and to interact with the program set is what differentiates it from other programs. Table 1.1 presents a comparison between programming and scripting languages.
Table 1.1 Programming and scripting language comparison.
Programming language
Scripting language
Set of instructions executes a task
Based on script written for run time environment
Compiler based
Interpreter based
Develop from scratch
Can integrate with existing
Run independent of parent program
Run inside another program
Compiled into a more compact form, does not need to be interpreted
Can be interpreted within another program
Offer full usage of language
Faster execution
One‐shot conversion
Line‐by‐line conversion
Long development time
Shorter development time since less coding
C, C++, C#, Java, VB, COBOL, PASCAL
JavaScript, Tcl, Perl, PHP, Ruby, Lua, Shell
Low development time
Easy integration with Tk
Cross‐platform independence can access with Windows, Mac, Unix
Inclusion into another programming languages
Open‐source
Command‐based operation
Dynamically redefined and overridden
Data types are based on strings
Event‐driven interface
A Tcl application requires a Tcl interpreter and a text editor. Nomenclature and version of the editor would be different depending on the operating system. Vi is preferred for UNIX or LINUX systems and notepad for Windows as a .tcl file. A Tcl script development with a text editor must be saved with the extension .tcl, which is known as the source file. The interpreter enables us to execute the Tcl command line by line. The latest version of the Tcl installer for the Windows operating system can be downloaded from http://activestate.com. The latest stable version is tcl8.6.
There is a different mechanism to access the Tcl interpreter
Search ➔ tclsh
Figure 1.1 shows a command‐line interpreter based on the Windows environment.
Figure 1.1 Command‐line interpreter.
Search ➔ wish
Figure 1.2 Wish interpreter.
Wish, i.e., Windowing Shell, is a Tcl interpreter, as presented in Figure 1.2, embedded with Tk; the Tcl command is read from a standard text editor or notepad. The Tcl command can be edited in the console window and wish in a smaller window to display the Tk widget. Alternatively, users can interact via importing the source file into the interpreter. A set of Tcl commands edited with notepad saved with the .tcl extension can be imported into the console.
File ➔ Source ➔ locate the file ➔ open search ➔ tkcon
Figure 1.3 Tkcon interpreter.
The tkcon interface shown in Figure 1.3 is a replacement of the standard console with Tk. It provides a GUI while the Tk commands are used in the program. Users can enter the program using a standard text editor or can import a source file.
File ➔ Load file ➔ Locate the file ➔ Open
Tcl includes some special variables that present their usage (see Figure 1.4). The following is a list of the special variables [3].
tcl_library
Sets the location of Tcl library.
tcl_version
Displays the current version of the interpreter.
tcl_patchLevel
Displays the current patch level.
tcl_interactive
Switches between interactive (1) and non‐interactive (0) mode.
tcl_precision
Displays the number of digits to generate when converting floating‐point values to strings.
tcl_rcFileName
Provides the user‐specific startup file.
tcl_pkgPath
Provides a list of directories where packages are installed.
Argc
Refers to several command‐line arguments.
Argv
Refers to the list containing the command‐line arguments.
argv0
Refers to the filename being interpreted.
env (PATH)
When Tcl starts, it creates the env array and reads the environment. It displays the array of elements for the environment variable.
Figure 1.4 Tcl special variable.
Tk is the most common extension of Tcl, and enables the creation and manipulation of the interface widgets. Advantages of the GUI design with command‐line arguments are (i) faster development, (ii) a higher level of interface than other standard library toolkits, (iii) interface can be factorized with user application.
The following online platforms prove that an online interpreter does not need to be installed:
https://onecompiler.com/tcl
https://rextester.com/l/tcl_online_compiler
https://ideone.com/l/tcl
The following Tcl script displays a statement at the std. output [4]:
puts “Hello Tcl World”
Each line of the script can be terminated by a newline or semicolon (;). A script can be stopped from execution via commenting by adding a hash (#) at the beginning. Figure 1.5 displays a simple program to display.
Figure 1.5 Tcl simple program.
Tcl is a case‐sensitive language. Identifiers are the names used to identify the variable (defined by the user). An identifier can start with an alphabetical letter (A–Z/a–z), underscore (_), or numeric digit (0–9). It avoids characters such as @ and %.
Examples: var., Var, St1, s_1, prog50.
Whitespace in Tcl is known as a blank statement and the interpreter ignores it. Whitespace describes the blank, newline, tab character, or comment. It separates one part of the statement from another.
There are several reasons a developer may prefer a Tcl scripting language. The following are the most favorable applications for the Tcl language.
Cross‐platform application
Graphical user interface development
Software testing via API of the application
Scalable website
Embedded application
Web‐server hosting
1.
https://www.tcl.tk/software/tcltk/choose.html
2.
https://www.tutorialspoint.com/tcl-tk/index.htm
3.
https://www.activestate.com
4. Beebe, N.H. (2013).
A Bibliography of O'Reilly & Associates and O'Reilly Media. Inc. Publishers
. Department of Mathematics, University of Utah.
Tcl is a script‐based language that was developed by John Osterhout in 1989 (University of California, Berkeley). It has a lower number of keywords and syntax compared with others making it easy to learn. Windows‐based Tcl shells can be used as tclsh or wish, as shown in Figures 2.1 and 2.2, respectively. The first is similar to a C‐shell while the second is a Tcl interpreter that extends its Tk command to create and manipulate widgets. The console window executes the Tcl program and the graphical user interface (GUI) developed with Tk widgets appears in the wish window. Console and wish are intractable. Both shells print a % prompt and execute the Tcl command and print the result sequentially. A Tcl program saves with an extension of .tcl.
Figure 2.1 Tclsh screen.
The basic syntax of a Tcl program is
Command arg1, arg2,…………. Argn