Quick Start       Pattern Matching        Commands      LAPIS Home

LAPIS

Commands

LAPIS includes a variety of commands that manipulate web pages and text documents. This tutorial provides a brief flavor of the commands available.

Keep/Omit
In the Pattern box at right, type row contains M in 4th cell in row and press Enter to select the courses that meet on Monday. Then pull down the Tools menu and select Keep. The course list should now show only the classes that were selected. The same result could be achieved by selecting the courses that don't meet on Monday (row not containing M in 4th cell in row) and invoking Tools/Omit instead.
Sort
In the Pattern box at right, type row and press Enter. Then pull down the Tools menu and select Sort. A dialog box should appear. In the "Part of record matching" box, type 3rd cell in row, and press OK. The course list should now be sorted by lecturer's name.

15-712
Advanced Operating Systems
Gibson
MW
10:00-11:20
WeH 5409A&B
12
15-750
Algorithms
Blum/Sleator
TR
1:30-2:50
WeH 5409A&B
9
15-780/16-731
Advanced AI Concepts
Moore
TR
10:30-11:50
WeH 5409A&B
12
20-602/15-802
Statistical Approaches to Learning
Fienberg/Lafferty
TR
12:00-1:20
PH A22
12
15-819
Typed Compilation
Crary
MW
1:30-2:50
WeH 5409B
12
15-819
Denotational Semantics of  Types
Reynolds
TR
10:30-11:50
WeH 4601
9
15-812
Semantics of  Programming Languages
Brookes
MWF
10:00-10:50
WeH 4615A
12
15-810
Verification of Real-Time Programs
Clarke
M
12:30-1:50
WeH 4601
6
80-713
Category Theory
Awodey
TR
1:30-2:50

12
15-822
System Design and Implementation
Satya
T
3:00-5:50
WeH 8220
15
15-824
Mobile and Wireless Networking
Johnson
TR
10:30-11:50
WeH 4615A
12

The Command box at the top of the LAPIS window accepts not only URLs, but also commands with arguments. Commands are statements in Tcl, a simple scripting language. A command can invoke a built-in tool, a Tcl script, or an external program. The output of a command is displayed in the browser.

Try some of these examples to see what they do.
extract word
Type or copy this command to the Command box, and press Enter. This command extracts all the words in this page. (Press the Back button to return to this page.) If you look at the Tools menu, you'll notice Extract is found there too. Each tool has a corresponding Tcl command: extract, keep, delete, sort, replace, calc, etc.
enter textbox rhizome ; click {first button}
The enter command puts "rhizome" in the textbox in the form below, just as if you had typed it. Then the click command clicks on the "Look up definition" button, which looks up "rhizome" in an online dictionary and returns a page showing its definition. (Press the Back button to return to this page.) This example shows how commands can be used to script web interactions.
Hypertext Webster Gateway (http://smac.ucsd.edu/cgi-bin/http_webster)

Enter word here:
Exact Approx

When you want to write a script of several commands, the Command box is too constraining.  You can use the Script Editor instead (Scripts menu, Script Editor command).

Bring up the Script editor and copy some of these examples into it to see what they do.
extract word -as text
sort word -order unicode
uniq
This example extracts the words from the page (as text, instead of the default HTML), sorts them (case-sensitively, instead of the default case-insensitive sort), and then runs the external program uniq to eliminate duplicates. (Note: Since Microsoft Windows doesn't have the uniq command, this command will probably fail on Windows.
ls
keep {line ending .html}
eval wc [lines]
This example runs ls to list the files in the current directory, filters to filenames ending ".html", and then runs the external program wc to count words in those files. (Note: Since Microsoft Windows doesn't have these external programs, this command will fail on Windows.) The last command needs some extra explanation: lines is a shortcut for extract Line -as tcl, which converts the lines in ls output into a Tcl list. The eval command then expands that list into arguments for wc. Without eval,wc would see only one argument containing all the filenames, instead of one argument for each filename. 


More Information

Most commands will display a usage message if you type command -help. A list of the available commands can be obtained by running info commands. You can also look at the command reference manual:
Go to the LAPIS home page.
Send comments or questions to Rob Miller, (rcm@lcs.mit.edu)
Copyright©2003 - Massachusetts Institute of Technology. All Rights Reserved.