1/9/2024 0 Comments Activetcl run tcl scriptIt's just $.īefore it called set, Tcl substituted $greeting with hello and $addressee with world. Between double quotes, $ tells Tcl to do variable substitution, but between braces, $ is not special. The double quotes, like the braces in the previous example, tell Tcl that $greeting, $addressee is a single word to be given to puts. $ tells Tcl to retrieve the value out of some variable and substitute that value into the place of the variable. The first word to set is the name of a variable, and the second word is the value to assign to that name. $greeting and $addressee are both variables. To interpret a script, Tcl reads the text of each command, looks up the command by the first word in the text, prepares the arguments to the command as described by any other words in the text, and invokes the command, passing it the prepared arguments.Ī word can be assigned to a variable, which can then be used in place of the literal word: puts accepts either one or two arguments, and in the script above, there was only one: hello world.Ī Tcl script is nothing more than a sequence of Tcl commands. These additional words are called arguments. The first word of each command is the name of the command, and any additional words are the values that Tcl passes to the command when invoking it. Unlike English, in Tcl any single value is referred to as a word. Like English, Tcl normally separates words by looking for the whitespace between them, but the braces around hello, world tell Tcl that it is a single value, including the whitespace. The program you just ran was a complete Tcl script, comprised of one command, puts, and one word, hello world. RS: Another possibility on Windows: add the line Note that the traditional Windows \ is replaced with /. You can run this program by starting tclsh from the start menu, then typing the command source c:/hello.tcl. But since our simple script doesn't create any windows, and it isn't clear where the words "hello, world" would go, this program won't appear to do too much. Just put the file on the desktop or find it in the explorer and click on it. tcl files in the wish shell, as a graphical application. The default Tcl/Tk installation on Windows runs all. Windows distinguishes between "console" applications, which run in a terminal window environment, and "windows" applications, which have a GUI. If you are a Microsoft Windows user, running a scripts is a little more complicated. your Tcl shell could be named ' tclsh', 'tclsh8.3', or some other numbered variant. Depending on your operating system, the particular version installation, etc. The next step is to use the Tcl shell to interpret your program. Using your favorite text editor, save the example above to a file named "hello.tcl".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |