Control structures like if/else statements, for loops, and switch cases are vital to writing program logic. These code snippets will serve as easy references for these control structures when writing with the Tcl programming language
There are many situations where it is useful to ask the user for some information while a program is running. Tcl makes this a breeze. Check out these code snippets that demonstrate how to interact with the user and manipulate input.
Tcl programs can accept command line arguments to pass runtime variables. These code examples show how to make use of these arguments.
Tcl provides an easy way to open and read the lines of a file. Check out these code snippets that demonstrate how to read and write files with Tcl programming language.
Tcl is a language similar Bash because every line is a command and it can be scripted similar to shell scripts. Tcl can be used by itself but it typically embedded inside larger applications. Tcl with Tk toolkit allows you to create GUI applications. Once nice thing about Tcl/Tk is that it is widely available and works on multiple platforms. It does not create the nicest looking GUIs because it does not use native windows, but they are effective. Let's look at the most basic Hello World program. Let's name it hello.tcl.
Writing a Chrome extension is incredibly easy! You don't need any special tools either, just a text editor and Chrome. Create a folder and make a manifest.json and an index.html file. Fill them in with the information below and you are ready to go!
It is possible to write GTK2 application using PHP. It is a little work to get it compiled and installed, but once configured it is easy to write programs with GTK2. As of June 22, 2015 a development branch has been created for GTK3. Follow these installation instructions first. Then try out the code samples below. Load the php-gtk2 module in your php.ini as well.
PHP Simple HTML DOM is a one-file library that lets you traverse the elements of an HTML and search for specific elements. The examples below show how to use this library. To learn how to crawl (or spider) websites in order to get many pages to process see this post on How to Crawl Web Pages with PHP
Uwe Hunfeld provides an object oriented library called PHPCrawl available at http://phpcrawl.cuab.de. This class can be used to crawl web pages with many different parameters. It also allows you to process each page and do what manipulation or scraping you need to do. You accomplish this by overriding the base class and implementing your own functionality in the handleDocumentInfo() and handleHeaderInfo() functions. Use the code below as an example of how to create your own web crawler. If you want to learn how to parse the HTML DOM and extract things like links and headings, check out the post on How to Parse HTML DOM with PHP.
PHP/TK implements object oriented bindings for TCL/TK that can be used to create GUI applications. It only works on Unix systems. PHP must be configured to allow dynamic linking with enable_dl = On in the php.ini. The shared object file (tk.so) can be downloaded manually from PECL. The shared object file goes inside your php modules folder which is typically something like /usr/lib/php/modules. Look for the folder with other .so files or refer to your particular distribution documentation.