122 lab week 1


SKILL ASSESSMENT NOTATION: In 122, we'll assess skill-acquisition using three levels: E (Exposure), F (Familiarity), M (Mastery).

In addition to O26 Kla, You can work in 013 Kla and 101 Mck or in any CC microlab on campus. You can also work from home (or any other computer) if you have an internet connection, or you have Mac OS X or another Unix machine.

GOALS FOR WEEK 1: At the end of lab, your skill level should be at E-level with the following topics:

    Basic Unix Commands
    Basic Emacs commands
    Basic Edit/Compile/Execute procedure for  "Hello World"
    

LAB OUTLINE:

UNIX

Go to http://www.uoregon.edu/~hak/unix-ws.html

These are the Unix commands you must learn in order to complete your 122 projects on gladstone. These commands may (will) appear on the quiz. (This link is also on the "Learning Unix" class page.)

Use SSH to login to gladstone (or darkwing, or another Unix machine), move to public_html (or create a public_html directory if you need to) and make a directory named 122 (not cis122 or anything else).

Move to 122 and make directories named p1, p2, p3, p4.

EMACS

Go to Learning Emacs

These are the Emacs commands you must learn in order to complete your 122 projects on gladstone. You will be responsible for a subset of commands for quiz purposes, however coding will go more quickly if you become familiar with all the commands.

PROGRAMMING : HELLO WORLD!

Move to ~/public_html/122/p1 and enter the command "emacs hello.cpp". Or, if Emacs is already running, use the Find File command (cntrl-x cntrl-f) to create the new file.

Follow the handout's directions to edit/compile/execute the following hello.cpp program.

//FILE:  hello.cpp

#include <iostream>           // for cout
using namespace std;

int main(){
    cout << endl << "Hello, " << endl << "Watson!" << endl;
    return 1;
}

Compile your program with one of our two c++ compilers: g++ or CC.

  1. Esc-X compile.
  2. You will be prompted with make -k the first time.
  3. type: g++ -o hello hello.cpp (remove the make -k)
  4. emacs will create two buffers - your code will appear in one, and the result of your compile in the other.
  5. If you have bugs (your program did not compile), and you're not sure why, now is a good time to ask for help.

Suspend Emacs (cntrl-z), and run hello from the command line.

LEARN the difference between Suspending emacs and Exiting emacs. Read the handout and try running your program without suspending emacs.

NOTE: when emacs is suspended in the background, you must RESUME emacs. If you enter the "emacs hello.cpp" command again, you will have multiple emacs processes running, which irritates the gladstone systems staff.

Resume emacs with the shell command %1 (resume job 1).

Debugging

Once you have the program running introduce some errors. Misspell cout as count. What happens when you try to compile? (Fix it.)

Remove the semicolon from the cout statement; Compile again.

Practice using the Parse Errors command (c-x `) (see the handout.)

Restore the "one window display" with c-x 1.

Printers now have an associated fee. You may either print your work (and pay the fee) or wait until you are on your home computer, download the file using FTP software, and print there.

Make sure you quit emacs before you go!