Week 1: Basic Command Line Usage, TclTutor

Opening the command line:

  • Today's class began with opening the command line. Under MacOSX you can get to in from Applications->Utilities->Terminal
  • Once you have the command line open you will see something like this:

    computername:~ username$

  • This called the command prompt. Essentially, it's a way of passing commands to the computer by typeing them out instead of clicking and dragging. Sometimes it's easier to do things from the command line. In other cases, developers couldn't figure out a way to visually represent a command sequence. Just know that TCL, the programming language you will be writing in, was designed to automate the process of sending commands to the system in this way.
  • First we created a tcl directory to store all of our files, and then use "change directory (cd)" to enter that directory.
    1. mkdir ~/tcl
    2. cd ~/tcl
  • Next we downloaded TclTutor. You can grab a copy from Downloads Directory
    1. Download the "Tutor2b4.tar" file
    2. Unzip the File:
      1. cd ~/tcl
      2. tar xf ~/Desktop/Tutor2b4.tar
    3. Once you have TclTutor, you can run it by:
      1. cd ~/tcl/TclTutor
      2. wish TclTutor.tcl
    4. More instructions about how to use TclTutor can be found: http://www.msen.com/~clif/TclTutor.html
  • During class we used the "nano" text editor built into OS X. It was a bit difficult because the keystrokes are decidedly un-Maclike. So for future classes we will use TkNotepad
    1. Download notepad.tcl from the Downloads directory
    2. Move the notepad.tcl file to your tcl directory:
      1. mv ~/Desktop/notepad.tcl ~/tcl/
    3. To run: wish ~/tcl/notepad.tcl
  • Next we wrote a short program in Tcl
    1. wish ~/tcl/notepad.tcl ~/tcl/helloworld.tcl
    2. type: puts "Hello World"
    3. save, exit
    4. wish ~/tcl/helloworld.tcl
  • We also showed that Tcl can be run interactively
    1. type "wish" on the command line
    2. type "puts {Hello World}"
    3. You should see "Hello World" print out on the display
    4. type "source ~/tcl/helloworld.tcl"
    5. You should see "Hello World" print out on the display
  • Finally we went on the Tcl'ers Wiki, copied the code of the Asteroids game, and played it in class.
      Open a web browser to http://wiki.tcl.tk
    1. Search for "Asteroids"
    2. Pull up the page, the complete code for asteroids is the red text with the gray background
    3. (There is more than one version, they each work)
    4. Open notepad (wish ~/tcl/notepad.tcl)
    5. Copy the text from code on the website, paste it into the notepad
    6. Save as ~/tcl/asteroids.tcl
    7. Exit notepad
    8. run: wish ~/tcl/asteroids.tcl
    9. A copy of the asteroids program is also in the Downoads folder

    Questions? swoods@fi.edu
    Last modified: Fri Oct 19 15:09:57 EDT 2007