Dr Scheme Tutorial

 

 

 

Table of Contents

 

How to Load DrScheme

         From the dock

         From the hard drive

         Choosing a language

How to Use DrScheme

         Interactions Window

         Definitions Window

How to Save and Edit Your Work

         Saving Your Work

         Editing Text Files

How to Submit Your Work

         Printing Your Work (CMSC 151)

         Submitting Your Work via a Dropbox (CMSC 105)

         Using the Handin Command (CMSC 161)

Some Debugging Tips

         Red/Black Coloring

         Syntax Checker

         Stepper

Using Extra Packages

         Installing a .PLT file

         Adding a Teachpack

         Adding an image

DrScheme Help Desk

 

 

How to Load DrScheme

 

From the dock

 

If the red and blue DrScheme logo appears in the dock along the bottom of the screen, select the shortcut to start DrScheme.

 

From the hard drive

 

If the shortcut is not in the dock, you can start DrScheme by selecting Macintosh HD -> Applications -> PLT v205 -> DrScheme

 

 

 

Choosing a Language

 

If this is the first time you are running DrScheme on this computer, you will be asked to choose your language. If it is not, then select Language -> Choose Language now.

 

 

You should select the Beginning Student language. The beginning student setting will allow you to do all the exercises for class, and it provides some additional debugging functionality that the more advanced levels do not provide.

 

 

 

After clicking OK, click the green Execute button. You will find that after pretty much any change, you need to click Execute.

 

 

Go to top

 

 

 

 

How to Use DrScheme

 

DrScheme is divided into two windows Ð the Interactions window (bottom) and the Definitions window (top).

 

 

Interactions Window

 

The Interactions Window behaves like a pocket calculator.When you enter commands in the Interactions window, they are executed as soon as you press Enter. You can use this window to test short pieces of code, or to run functions that you define in the Definitions window. The text you enter is displayed in black after the > sign, and the programÕs responses are displayed in blue.

 

 

You can define functions and variables in either window, and perform all scheme commands. Any output from those commands appears immediately below.

 

           

 

Definitions Window

 

In the Definitions window, statements are entered all at once, and then run all at the same time. To execute the contents of the Definitions window, click the green Execute button. Any output from the statements goes into the Interactions window.

 

 

For example, if I enter (+ 4 4) in the Definitions window, then the Interactions window will display 8 as a result.

 

 

Usually the Definitions window is used to define functions, which can then be tested in the Interactions window. However, any statement, not just (define É) statements, can be executed from the Definitions window.

 

 

You must click the Execute button each time you want to test your work in the Interactions window. If you forget to do this, then DrScheme will give you a yellow warning, and it will run with the old definitions.

 

 

 

 

Go to top

 

 

 

 

How to Save and Edit Your Work

 

Saving Your Work

 

To Save your definitions, click the blue Save button.

 

 

When it asks you for the location and name, choose a filename. Usually Scheme files have a .scm extension, but that is not a requirement.

 

 

To save your Interactions, select File -> Save Other -> Save Interactions É . Usually you need to submit both your Interactions and Definitions with your homework. Check with your teacher for specific requirements.

 

 

Editing Text Files

 

For many assignments, you may need to edit data files or explanatory files to go along with your homework. You may also want to view your .scm files in another program Ð since they are stored as plain text, that is not difficult. You can use your favorite plain text editor on whatever system you are using. These may be:

-       Windows:  Notepad, Wordpad

-       Linux:  emacs, xemacs, pico, vi

-       Mac: BBEdit, TextEdit

 

For this example we will use the Macintosh BBEdit Lite. Open BBEdit either from the dock, or by going to Macintosh HD -> Applications -> BBEdit Lite 6.1 and selecting BBEdit Lite 6.1 for OS X

 

 

You can then edit any text file you want to. In this example, we will edit a DrScheme program, and then open it in DrScheme

 

 

 

You can save the file anywhere (here in Documents).

 

 

Then open it in DrScheme.

 

 

 

How to Submit Your Work

 

Printing Your Work (for CMSC 15100)

 

If your teacher requires you to submit a hard-copy, then print your Interactions and Definitions separately by selecting File->Print Interactions and File->Print Definitions. Then hand them in.

 

 

Submitting Your Work Via A Dropbox (for CMSC 10500)

 

Submitting via Appleshare (from a Macintosh)

 

To submit your work from a Macintosh (either in the Maclab or elsewhere), click on the Finder logo in the dock.

 

 

Then select Go -> Connect to Server from the menu bar.

 


 

At the Address: prompt, enter ja3.cs.uchicago.edu.

 

 

 

Log in as Guest. When it asks which volumes to mount, select Courses. Click OK. An icon labeled Courses should appear on your desktop.

 

 

Double-click on Courses, then browse to Autumn 2003 -> CS10500 -> CS10500-Your section. You can move your files into the Drop Box folder. Note that it really is a drop box Ð you cannot view, edit, or remove files once they are in the Drop Box.

 

Submitting via FTP (from Windows)

 

If you would like to submit your work from home, you can do so by using a Secure FTP program (for example, Secure SSH SFTP). FTP to ja3.cs.uchicago.edu with login scheme and password fairy. Then navigate to /Volumes/Courses/Autumn 2003/CS10500/CS10500-Your Section. The dropbox should work the same way here.

 

Submitting Using handin (for CMSC 16100)

 

One way of using handin is to do it from a Linux machine in the Maclab. However, you can also do it from any Windows or Macintosh computer, using an SFTP program and an SSH program. Both of these are available for Windows at http://www.ssh.com. Download the single package called SSH Secure Shell. On a Mac, we will use MacSFTP and the Terminal window.

 

Edit your DrScheme files, text files, etc., and store them all in a single directory. Then open MacSFTP by clicking on the link in the dock.

 

 

Connect to any Linux server. In this case IÕm going to connect to classes.cs.uchicago.edu. From the Maclab, you can just type classes.

 

 

If itÕs your first time, I would suggest creating a directory just for your DrScheme files, and maybe even a subdirectory for each homework assignment. Right click in the window and click on Create Directory.

 

 

Finally, copy your files over to the server by dragging them into your new homework folder. In this example, I created the folder scheme and then a subfolder hw1.

 

 

At this point, the homework is not submitted, it is just in your own home directory. You need to submit the homework to OÕDonnell using his handin command. You can use the Terminal program, which should be in the dock, but if not, it is at Macintosh HD -> Applications -> Utilities -> Terminal. Click on File -> New Shell from inside the Terminal program to bring up a new shell. Now you need to log into classes. Enter ssh username@classes to log into the machine. If asked to accept a new key, enter yes. Then enter your password. Finally, once  you are logged in, cd to the directory where your files are stored, and execute the handin command. As suggested on OÕDonnellÕs website, you may want to add his home directory to your path. He suggests using export; IÕm using set because export doesnÕt work with my shell. These commands are shown below.

 

 

Using this method, you can work on your scheme files at home and submit them over the Internet.

 

 

 

Go to top

 

 

Debugging Your Scheme Files

 

 

Red/Black Coloring

 

Many times you will create programs that will branch depending on the input it is given. To test these programs, you must create a series of test cases. DrScheme provides the ability to make sure that your test cases cover all of your code. If a section of code is run, then it turns black Ð otherwise, it stays red.

 

 

In the above example, the function test-sign tests the sign of a given number. To make sure it works on all numbers, I have constructed a test case for some classes of numbers. But as you can see, I forgot to test the case where the number is negative. DrScheme tells me this by showing ÒnegativeÓ in red lettering, indicating that that portion of the code was never run. As soon as it is run, however, it turns black.

 

 

 

Syntax Checking

 

DrScheme will check your syntax for you, and allow you to see visually the relationships between your functions and variables by coloring them for you. You can do this by clicking the Check Syntax button at the top of DrScheme window.

 

 

Then your variables are colored so you can see your code more easily. This makes it much easier to navigate very large scheme files.

 

 

 

Stepper

 

The stepper can be a very powerful diagnostic tool, although you should always be able to step through your program without this tool, by knowing how it works yourself. The stepper lets you drill down into your program, examining each expression as it is evaluated by the DrScheme engine. To step through your program, click the Step button.

 

 

Then you can view your program as it is processed by the DrScheme engine.

 

 

                                    

 

 

Go to top

 

 

 

 

Using Extra Packages

 

Installing a .PLT file

 

Some classes will require you to install extra packages. For example, Prof. FindlerÕs class is required to install the utils-151.plt. To do this, select File->Install .plt file É from the DrScheme menu bar. When prompted, select Web and enter http://people.cs.uchicago.edu/~robby/courses/15100-2003-fall/utils-151.plt. Then click OK and the package is installed.

 

 

 

 

Adding a Teachpack

 

To install a teachpack, select Language -> Add TeachpackÉ and then select your file. For example, to install Prof. FindlerÕs image-teachpack, download the image-teachpack.ss file to the DrScheme teachpacks directory, which is Macintosh HD->Applications->PLT v205->teachpack.

 

 

From DrScheme, click Language -> Add Teachpack É and browse to the location where you downloaded the teachpack.

 

 

 

Most importantly, after you install the teachpack, click the green Execute button or else it wonÕt run with the teachpack. When the teachpack is installed, you will get a message each time you click Execute, right below the announcement of the Language.

 

 

 

Adding an Image

 

You can insert images into DrScheme and treat them just like any other atomic variable. You can define variables as images, compare images, and if there are functions that are designed to use them, you can do that as well. To do this, you must first download an image. In this example, I will use a picture of Don Randel, which can be found at http://www.maclab.cs.uchicago.edu/tutorials/randel.jpg. Download this picture and store it on your desktop, by visiting this site, right clicking on the image, and selecting Download image to disk É, then choosing your Desktop.

 

 

In DrScheme, enter (define randel. Then choose Special->Insert ImageÉ from the menu bar.

 

Select randel.jpg from the Desktop, and click Open. Enter the) to close the parentheses. Don Randel should now appear in your Definitions window, and his image will behave just like any other defined value, such as a function, number, list, or other special object.

 

 

You can see if this worked by clicking the green Execute button and then entering randel into the Interactions window and pressing Enter.

 

 

 

Go to top

 

 

 

DrScheme Help Desk

 

The help desk can be accessed from the Help menu by clicking on Help Desk. The welcome screen allows for browsing categorically or by entering a keyword.

 

 

 

If you have any further questions about DrScheme, or if you need assistance with any of the keywords of the Scheme language itself, the DrScheme Help Desk is an excellent resource. If you have a problem, consult the help desk first, and then your T.A. Good luck!

 

 

Go to top