Command
Reference
This page lists the script
commands recognized by LAPIS, in alphabetical order. Only the new commands
defined by LAPIS are described here. For more about Tcl, the scripting
language used by LAPIS, consult these other references:
Back
- back [n]
Backs up to
the previous document in the page history. The optional argument n is the
number of pages to back up. This command has the same effect as the Back
toolbar button.
Calc
- calc pattern
[-count]
[-sum]
[-average|-mean|-avg]
[-min]
[-max]
[-stddev]
Calculates statistics
on the regions matching pattern. Only numeric regions
are included in the statistics; nonnumeric regions are ignored. The statistics
returned depend on which options are given:
- -count returns the number of numeric regions matching the pattern
- -sum returns the sum
- -average returns the mean of the regions. -mean and -avg are synonyms.
- -min returns the minimum of the matching regions
- -max returns the maximum
- -stddev returns the standard deviation
If only one
option is given, then calc returns only the computed value. If multiple
options are given, then calc returns a Tcl list of values in the order the
options were given. If no options are given, calc computes all the statistics
and returns a formatted display.
Click
- click pattern
Clicks on the
hyperlink or form control described by pattern. Throws a Tcl exception
if pattern
does not match exactly one hyperlink or form control.
Count
- count pattern
Returns the
number of matches to pattern.
Delete
- delete pattern
Deletes all
regions matching pattern. Synonym for omit.
Doc
- doc [string]
Returns the
current document
- doc string [-type type]
Sets the current
document to string. With -type, the document
is created with content type type. Possible content types
are text and html. Without this argument, the content type is guessed from
the content of string, defaulting to text if
no valid HTML tags are found.
Enter
- enter pattern value
Sets all form
fields matching pattern to the value value.
- For text fields, value is a string which is entered in
the field.
- For menus and lists, value is the name of the selected
value.
- For radio buttons and checkboxes, value should be one
of the following: on, off, yes, no,true,false,0,1.
Exec:
- exec:command
Runs command as an external program.
Extract
- extract pattern
[-startswith start]
[-endswith end]
[-separatedby sep]
[-as type]
Extracts all
regions matching pattern.
- -startswith prints start before each extracted region.
- -endswith prints end after each extraction region.
- -separatedby prints sep between each pair of regions (after
the previous region's end and before the next region's start).
- -as converts the extracted regions to type, which may be
either text or html.
File:
- file:filename
Loads the file
named filename and returns it as the current
document.
Forward
- forward [n]
Goes forward
to the next document in the page history. The optional argument n is the
number of pages to go forward. This command has the same effect as the Forward
toolbar button.
Ftp:
- ftp://hostname/pathname
Retrieves a
file by FTP and returns it as the current document.
History
- history
Prints the page
history to standard output. This command is designed for the LAPIS typescript
shell (lapis -tty), which would otherwise have no other way to show the history.
Http:
- http://hostname/pathname
Retrieves a
web page by HTTP and returns it as the current document.
Insert
- insert pattern string
Inserts string at all points matched by
pattern. Synonym for replace.
Keep
- keep pattern [-outof recordpattern]
Keeps only records
matching pattern and deletes the rest.
- -outof specifies a record set rather than inferring it from pattern.
Omit
- omit pattern
Deletes all
regions matching pattern.
Parse
- parse parser
Binds the patterns
described by parser into the pattern library.
The parser can be one of three possibilities:
- a filename ending in .tcl, which is interpreted as a script of
Tcl commands;
- a filename ending in .tc, which is interpreted as a file of TC
patterns;
- the name of a Java class implementing lapis.Parser. The class
is loaded, an instance is created, and its bind method is called.
Property
- property [-get] name
Returns the
value of the property named name on the current document.
- property -set name value
Sets the name property to value.
- property -list
Returns a Tcl
list of the property names defined on the current document.
Relocate
- relocate
[-base url]
[-override]
Adds the HTML
element <base href=url> to the current document.
The url is obtained as follows:
- From the -base argument, if specified.
- From the base property of the current document, if any.
- From the url property of the current document, if any.
If none of these
can be found, relocate makes no change to the current document. If the
current document already has a <base> element, relocate does nothing
unless the -override option forces it to replace the existing <base>.
Replace
- replace pattern template
Replaces all
regions matching pattern with template. The template may include
embedded pattern substitutions surrounded by curly braces.
Save
- save [filename]
[-backup extension]
Saves the current
document to filename, or to the file the current
document was loaded from if no filename is specified.
If the file already exists,
the old contents are backed up to filename by default. The -backup
option changes the backup extension from to extension. If extension
is the empty string, backup is disabled.
Show
- show [-brief] [-all]
Prints the content
of the current document to standard output. This command is designed for
use in the LAPIS typescript shell (lapis -tty) and for scripts run from
the command line.
- -brief displays at most a fixed number of lines, half from the
start of the document and half from the end. The number of lines displayed
is controlled by the Tcl variable lapis::displayLimit, which defaults to
25. This is the default when show is called interactively.
- -all displays the entire document. This is the default when show
is used in a script.
Sort
- sort pattern
[-by keypattern]
[-order [reverse] dictionary|numeric|unicode|random]
Sorts the regions
matching pattern.
- -by specifies a sort key in each record. If no -by option is specified,
the entire record is used as a sort key.
- -order specifies the sort order. Default is dictionary.
Multiple sort
keys may be specified with multiple -by and -order arguments.
Submit
- submit [-form formpattern]
[-button buttonpattern]
Submits a web
form in the current page.
- -form specifies the form to submit. If -form is omitted, the first
form in the page is used.
- -button specifies the button that should be pressed to submit
the form. If no -button argument is given, the first button of type submit
is pressed.
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.