Summary Documentation: Basic Programs

Library version 9.4.3



adlcheck.icn: Program to check for bad address list data

This program checks address lists for correctness.

There are five options:

   -s      Check state (U.S. labels only)
   -z      Check ZIP code (U.S. labels only)
   -c      Check country name (a very heuristic check)
   -a      Check all of the above
   -d      Report addresses that exceed "standard dimensions" for labels:
              40 character line length, 8 lines per entry

[ Full documentation | Source code ]


adlcount.icn: Program to count address list entries

   This program counts the number of entries in an address list file.
If an argument is given, it counts only those that have designators
with characters in the argument. Otherwise, it counts all entries.

[ Full documentation | Source code ]


adlfiltr.icn: Program to filter address list entries

  This program filters address lists, allowing through only those entries
with specified selectors.

  The options are:

     -s arg  selects entries with characters in args (default is all)
     -x      inverts the logic, selecting characters not in args

[ Full documentation | Source code ]


adlfirst.icn: Program to write first line of addresses

   This program writes the first lines of entries in an address list file.
If an argument is given, it counts only those that have designators
with characters in the argument. Otherwise, it counts all entries.

[ Full documentation | Source code ]


adllist.icn: Program to list address list fields

This program lists entries in address lists. The options are:

   -c      by country
   -n      by name
   -C      by city (U.S. only)
   -s      by state (U.S. only)
   -z      by ZIP code (U.S. only)

   The default is -n.  If more than one option is specified, the
   order of dominance is -n -z -s -c -C.

[ Full documentation | Source code ]


adlsort.icn: Program to sort address list entries

This program sorts entries in address lists.  The options are:

   -c      by country
   -n      by name
   -z      by ZIP code

   The default is -n.  If more than one option is specified, the
   order of dominance is -n -z -c.

[ Full documentation | Source code ]


animal.icn: Program to play "animal" guessing game

   This is the familiar ``animal game'' written in Icon.  The
program asks its human opponent a series of questions in an attempt
to guess what animal he or she is thinking of.  It is an ``expert
system'' that starts out with limited knowledge, knowing only one
question, but gets smarter as it plays and learns from its opponents.
At the conclusion of a session, the program asks permission to
remember for future sessions that which it learned.  The saved file
is an editable text file, so typos entered during the heat of battle
can be corrected.

   The game is not limited to guessing only animals.  By simply
modifying the first two lines of procedure "main" a program can be
created that will happily build a knowledge base in other categories.
For example, the lines:

        GameObject := "president"
        Tree := Question("Has he ever been known as Bonzo",
           "Reagan","Lincoln")

can be substituted, the program works reasonably well, and could even
pass as educational.  The knowledge files will automatically be kept
separate, too.

   Typing "list" at any yes/no prompt will show an inventory of
animals known, and there are some other commands too (see procedure
Confirm).

[ Full documentation | Source code ]


applyfnc.icn: Program to apply function to lines of a file

This program applies a function specified on the command line to the
lines of a file.

[ Full documentation | Source code ]


banner.icn: Program to display banner

   Here is a a handy little code fragment called banner. I
know icon is mostly in the unix world and unix already has a banner
command. But I'm mostly in the DOS and VMS world so I offer this little
banner code. It outputs enlarged letters (5x6 matrix) portraite. With a
little diddling you can change the scale or font since this is the source.
Maybe it can be made to take an input file as a font, and maybe even from
xwindows. But this is a simple one. I include a main() procedure that
calls it so you can test it and build from there. Enjoy!

[ Full documentation | Source code ]


based.icn: Program to do BASIC-style editing

This program models a line editor for BASIC.

[ Full documentation | Source code ]


bfd.icn: Program to compute best-fit-descending bin packing

Usage:  bpack binsize [options] [file]

Input:  one entry per line, size in decimal followed by anything else
        (anything else presumably being a file name or something)

Output: all the input lines, unchanged but reordered,
        with an empty line before each bin and a total afterward

Options:
     -t      don't output anything except unannotated totals
     -n      don't output anything except the *number* of bins
     -b i    don't output anything except the details from bin i

[ Full documentation | Source code ]


bj.icn: Program to play blackjack game

Simple but fun blackjack game.  The original version was for an ANSI
screen.  This version has been modified to work with the UNIX termcap
database file.

[ Full documentation | Source code ]


blnk2tab.icn: Program to convert strings of 2 or more blanks to tabs

This program converts strings of two or more blanks to tabs.  It
reads from standard input and writes to standard output.

[ Full documentation | Source code ]


c2icn.icn: Program to assist C-to-Icon porting

Filter to do some of the mundane work involved in porting a C
program to Icon.

- Reformats comments, moving embedded comments to end of line
- Removes the ";" from ends of lines
- Reformats line-continued strings
- Changes = to :=
- Changes -> to .

[ Full documentation | Source code ]


calc.icn: Program to simulate desk calculator

This is a simple Polish "desk calculator".  It accepts as values Icon
integers, reals, csets, and strings (as they would appear in an Icon
program) as well as an empty line for the null value.

Other lines of input are interpreted as operations. These may be Icon
operators, functions, or the commands listed below.

In the case of operator symbols, such as +, that correspond to both unary
and binary operations, the binary one is used.  Thus, the unary operation
is not available.

In case of Icon functions like write() that take an arbitrary number of
arguments, one argument is used.

The commands are:

     clear   remove all values from the calculator's stack
     dump    write out the contents of the stack
     quit    exit from the calculator

Example: the input lines

     "abc"
     3
     repl
     write

writes abcabcabc and leaves this as the top value on the stack.

Failure and most errors are detected, but in these cases, arguments are
consumed and not restored to the stack.

[ Full documentation | Source code ]


catlines.icn: Program to concatenate lines of a file

This program concatenates all the lines from standard input and
writes the result to standard output.

[ Full documentation | Source code ]


chars.icn: Program to list the different characters in a file

This program lists all the different characters in a file.  image()
is used to show printable representations.

[ Full documentation | Source code ]


chkhtml.icn: Program to check HTML files

Program to check an HTML file.

Errors detected:

  - Reference to undefined anchor name.
  - Duplicated anchor name.
  - Warning for unreferenced anchor name.
  - Unknown tag.
  - Badly formed tag.
  - Improper tag nesting.
  - Unescaped <, >, ", or &.
  - Bad escape string.
  - Improper embedding of attributes.
  - Bad (non-ascii) characters

Advises on:
  - Use of <HTML>, <HEAD, <BODY> tags.

[ Full documentation | Source code ]


choose.icn: Program to pick lines from a file

usage:  choose [-N] [file...]

This program randomly selects N lines from the input stream and
outputs them in order.  If N is omitted, one line is chosen.
If the input stream supplies fewer than N lines, all are output.

[ Full documentation | Source code ]


chop.icn: Program to restrict numerical values

This program limits the numerical values in a sequence
visualization stream.  The limit is given on the command line;
default 200.

[ Full documentation | Source code ]


colm.icn: Program to arrange data into columns

Program to arrange a number of data items, one per line, into
multiple columns. Items are arranged in column-wise order, that is,
the sequence runs down the first column, then down the second, etc.

If a null line appears in the input stream, it signifies a break in
the list, and the following line is taken as a title for the
following data items. No title precedes the initial sequence of
items.

Usage:

      colm [-w line_width] [-s space_between] [-m min_width]
              [-t tab_width] [-x] [-d] [file ...]

 The parameters are:

      line_width:     the maximum width allowed for output lines
                      (default: 80).
      space_between:  minimum number of spaces between items
                      (default: 2).
      min_width:      minimum width to be printed for each entry
                      (default: no minimum).
      tab_width:      tab width used to entab output lines.
                      (default: no tabs).
      -x              print items in row-wise order rather than
                      column-wise.
      -d (distribute) distribute columns throughout available width.

 The command "colm -h" generates "help" text.

 This is a  general utility,  but  it  was  written and tailored for a
 specific purpose:

 This  utility  was written  to rearrange the file name  list from the
 Macintosh  Programmer's   Workshop  "Files"  command  into   a   more
 convenient  format.  "Files" lists  file  names in a  single  column.
 This program  takes  the  list  produced by  "Files"  and  outputs  a
 multi-column  list.  The  names  are  listed  vertically within  each
 column, and  the column width is computed dynamically  depending upon
 the sizes  of the  names listed.  A  recommendation  is  to create  a
 command file "lc" (List in Columns) as follows:

      Files {"Parameters"} | colm

 The output from  the  Files command  is "piped" to the "colm" program
 (this program), which prints its list in the current window.

 By  putting both  the "lc"  command  file and the "colm" program into
 your {MPW}Tools folder, "lc" can be conveniently issued  as a command
 at any time, using the same parameters as the "Files" command.

[ Full documentation | Source code ]


comfiles.icn: Program to list common files in two directories

This program lists common file names in two directories given as
command-line arguments.

[ Full documentation | Source code ]


compare.icn: Program to look for duplicates in a collection of files

This program compares files to locate ones that have the same content.

The file names are given on the command line.

This program has impossible time complexity if there are many files
of the same size.

[ Full documentation | Source code ]


comply83.icn: Program to check compliance with MS-DOS name restrictions

This program checks the file names given on standard input and reports
any that are not valid MS-DOS file names.

It is designed handle output UNIX ls -R, but it will handle a list
of file names, one per line.

[ Full documentation | Source code ]


concord.icn: Program to produce concordance

   This program produces a simple concordance from standard input to standard
output. Words less than three characters long are ignored.

   There are two options:

     -l n    set maximum line length to n (default 72), starts new line
     -w n    set maximum width for word to n (default 15), truncates

   There are lots of possibilities for improving this program and adding
functionality to it. For example, a list of words to be ignored could be
provided.  The formatting could be made more flexible, and so on.

[ Full documentation | Source code ]


conman.icn: Program to convert units

Conman is a toy I used to teach myself elementary Icon.  I
once vaguely heard of a program which could respond to queries
like "? Volume of the earth in tbsp".

The keywords of the language (which are not reserved) are:

        load
        save
        print
        ? (same as print)
        list
        is and are which have the same effect

"Load" followed by an optional filename loads definitions of
units from a file.  If filename is not supplied, it defaults to
"conman.sav"

"Save" makes a file for "load".  Filename defaults to
"conman.sav".  "Save" appends to an existing file so a user
needs to periodically edit his save file to prune it back.

"Print" and "?" are used in phrases like:

        ? 5 minutes in seconds

Conman replies:

        5 minutes in seconds  equals  300

List puts up on the screen all the defined units and the
corresponding values.  Format is same as load/store format.

"Is" and "are" are used like this:

        100 cm are 1 meter

The discovery of is or are causes the preceding token (in
this case "cm") to be defined.  The load/store format is:

       unitname "is" value

Examples:

     8 furlongs is 1 mile
     furlong is 1 / 8 mile

These last two are equivalent.  Note spaces before and after
"/".  Continuing examples:

     1 fortnight is 14 days
     furlong/fortnight is furlong / fortnight
     inches/hour is inch / hour

After this a user might type:

     ? 1 furlong/fortnight in inches/hour

Conman will reply:

     1 furlong/fortnight in inches/hour equals 23.57

Note: the following feature of Conman:  his operators have no
precedence so the line above gets the right answer but

      1 furlong/fortnight in inches / hour

gets the wrong answer.  (One definition of a feature is a flaw we're
not going to fix).

[ Full documentation | Source code ]


countlst.icn: Program to count items in a list

   This program counts the number times each line of input occurs and
writes a summary.

   With no option, the output is sorted first by decreasing count and within
each count, alphabetically. With the option -a, the output is sorted
alphabetically.

The option -t prints a total at the end.

[ Full documentation | Source code ]


cross.icn: Program to display intersection of words

   This program takes a list of words and tries to arrange them
in cross-word format so that they intersect. Uppercase letters
are mapped into lowercase letters on input.  For example, the
input

        and
        eggplants
        elephants
        purple

produces the output
     +---------+
     | p       |
     | u e     |
     | r g     |
     | p g     |
     |elephants|
     | e l     |
     |   and   |
     |   n     |
     |   t     |
     |   s     |
     +---------+

Diagnostics: The program objects if the input contains a nonal-
phabetic character.

Comments: This program produces only one possible intersection
and it does not attempt to produce the most compact result.  The
program is not very fast, either.  There is a lot of room for
improvement here. In particular, it is natural for Icon to gen-
erate a sequence of solutions.

[ Full documentation | Source code ]


crypt.icn: Program to encrypt file

Do *not* use this in the face of competent cryptanalysis.

Usage: [iconx] icrypt [key] < infile > outfile

[ Full documentation | Source code ]


csgen.icn: Program to generate context-sensitive sentences

   This program accepts a context-sensitive production grammar
and generates randomly selected sentences from the corresponding
language.

   Uppercase letters stand for nonterminal symbols and -> indi-
cates the lefthand side can be rewritten by the righthand side.
Other characters are considered to be terminal symbols. Lines
beginning with # are considered to be comments and are ignored.
A line consisting of a nonterminal symbol followed by a colon and
a nonnegative integer i is a generation specification for i
instances of sentences for the language defined by the nontermi-
nal (goal) symbol.  An example of input to csgen is:

        #   a(n)b(n)c(n)
        #   Salomaa, p. 11.
        #   Attributed to M. Soittola.
        #
        X->abc
        X->aYbc
        Yb->bY
        Yc->Zbcc
        bZ->Zb
        aZ->aaY
        aZ->aa
        X:10

The output of csgen for this example is

        aaabbbccc
        aaaaaaaaabbbbbbbbbccccccccc
        abc
        aabbcc
        aabbcc
        aaabbbccc
        aabbcc
        abc
        aaaabbbbcccc
        aaabbbccc


   A positive integer followed by a colon can be prefixed to a
production to replicate that production, making its selection
more likely. For example,

        3:X->abc

is equivalent to

        X->abc
        X->abc
        X->abc

One option is supported:

     -g i    number of derivations; overrides the number specified
             in the grammar

Limitations: Nonterminal symbols can only be represented by sin-
gle uppercase letters, and there is no way to represent uppercase
letters as terminal symbols.

   There can be only one generation specification and it must
appear as the last line of input.

Comments: Generation of context-sensitive strings is a slow pro-
cess. It may not terminate, either because of a loop in the
rewriting rules or because of the progressive accumulation of
nonterminal symbols.  The program avoids deadlock, in which there
are no possible rewrites for a string in the derivation.

   This program would be improved if the specification of nonter-
minal symbols were more general, as in rsg.

[ Full documentation | Source code ]


cstrings.icn: Program to print strings in C files

Program to print all strings (enclosed in double quotes) in C source
files.

[ Full documentation | Source code ]


cwd.icn: Program to write current working directory

This program write the current working directory, shorn of it's
path specification.

For appropriately named directories, it can be used as, for example,

     ftp `cwd`

[ Full documentation | Source code ]


datmerge.icn: Program to merge data files

Datmerge reads and combines arbitrary text-based data files that
contain whitespace-separated data.  For each data field, a single
value is written to standard output after applying a selected
operator (such as median or minimum) to the corresponding values
from all the input files.

Usage:  datmerge [-operator] filename...

Operators:
    -min or -minimum
    -max or -maximum
    -med or -median   (this is the default)
    -mean

Values convertible to numeric are treated as such.
All others are treated as strings.

[ Full documentation | Source code ]


daystil.icn: Program to calculate the number of days until a given date

Usage:    daystil sMonth iDay

Returns:
    0   number of days written on &output
    1   Usage message on &errout (bad parameters)

Revision History:
    <1> njl  6/29/94 9:50 PM        First written

This program calculates the number of days between the current date
and the date specified on the command line, and writes this number to
&output.  This is useful if you want to know how many days it is
until a birthday, wedding day, etc.

The date on the command line can be specified in a variety of ways.
For instance, if you wanted to know how many days it is until
August 12 (my birthday), you could specify it as "August 12", "Aug 12",
"12 August", or "12 aUGuS", among others.  The match is case
insensitive, and the arguments will be accepted as long as exactly
one of them is an integer, and if there are exactly two arguments.

[ Full documentation | Source code ]


ddfdump.icn: Program to print the contents of an ISO 8211 DDF file

Usage:  ddfdump [file...]

Ddfdump prints the contents of Data Descriptive Files (DDF).
DDF is an incredibly complex file format enshrined by the
ISO 8211 standard and used by the United States Geological
Survey (USGS) for digital data.

[ Full documentation | Source code ]


deal.icn: Program to deal bridge hands

   This program shuffles, deals, and displays hands in the game
of bridge.  An example of the output of deal is
     ---------------------------------

               S: KQ987
               H: 52
               D: T94
               C: T82

     S: 3                S: JT4
     H: T7               H: J9863
     D: AKQ762           D: J85
     C: QJ94             C: K7

               S: A652
               H: AKQ4
               D: 3
               C: A653

     ---------------------------------

Options: The following options are available:

     -h n Produce n hands. The default is 1.

     -s n Set the seed for random generation to n.  Different
          seeds give different hands.  The default seed is 0.

[ Full documentation | Source code ]


declchck.icn: Program to detect possible declaration errors

This program examines ucode files and reports declared identifiers
that may conflict with function names.

[ Full documentation | Source code ]


delam.icn: Program to delaminate file

   This program delaminates standard input into several output
files according to the specified fields.  It writes the fields in
each line to the corresponding output files as individual lines.
If no data occurs in the specified position for a given input
line an empty output line is written. This insures that all out-
put files contain the same number of lines as the input file.

   If - is used for the input file, the standard input is read.
If - is used as an output file name, the corresponding field is
written to the standard output.

   The fields are defined by a list of field specifications,
separated by commas or colons, of the following form:

        n    the character in column n
        n-m  the characters in columns n through m
        n+m  m characters beginning at column n

where the columns in a line are numbered from 1 to the length of
the line.

   The use of delam is illustrated by the following examples.
The command

        delam 1-10,5 x.txt y.txt

reads standard input and writes characters 1 through 10 to file
x.txt and character 5 to file y.txt.  The command

        delam 10+5:1-10:1-10:80 mid x1 x2 end

writes characters 10 through 14 to mid, 1 through 10 to x1 and
x2, and character 80 to end.  The command

        delam 1-80,1-80 - -

copies standard input to standard output, replicating the first
eighty columns of each line twice.

[ Full documentation | Source code ]


delamc.icn: Program to delaminate file using tab characters

   This program delaminates standard input into several output
files according to the separator characters specified by the
string following the -t option.  It writes the fields in each
line to the corresponding output files as individual lines. If no
data occurs in the specified position for a given input line an
empty output line is written. This insures that all output files
contain the same number of lines as the input file.

   If - is used as an output file name, the corresponding field
is written to the standard output. If the -t option is not used,
an ascii horizontal tab character is assumed as the default field
separator.

   The use of delamc is illustrated by the following examples.
The command

        delamc labels opcodes operands

writes the fields of standard input, each of which is separated
by a tab character, to the output files labels, opcodes, and
operands.  The command

        delamc -t: scores names matric ps1 ps2 ps3

writes the fields of standard input, each of which are separated
by a colon, to the indicated output files.  The command

        delamc -t,: oldata f1 f2

separates the fields using either a comma or a colon.

[ Full documentation | Source code ]


dellines.icn: Program to delete lines from a file

This program is designed to delete a few specified lines from a file.
The line numbers are given on the command line, the file is read from
standard input and the lines that are not deleted are written to standard
output as in

     dellines 46 23 119 <infile >outfile

which writes all lines but 23, 46, and 119 of infile (if it contains that
many lines) to outfile.

Line numbers do not have to be given in order.  Numbers less than 1 are
ignored, but a nonnumerical argument is treated as an error.

[ Full documentation | Source code ]


delta.icn: Program to list differences between successive numbers

This program reads a stream of numbers from standard input and write
a stream of their first differences to standard output.

[ Full documentation | Source code ]


diffn.icn: Program to show differences among files

This program shows the differences between n files. Is is invoked as

     diffn file1 file2 ... filen

[ Full documentation | Source code ]


diffsort.icn: Program to reorder "diff" output

Usage:  diffsort [file]

Diffsort reorders the output from the Unix "diff" program by moving
one-line entries such as "Common subdirectory ..." and "Only in ..."
to the front of the output file and sorting them.  Actual difference
records then follow, in the original order, separated by lines of
equal signs.

[ Full documentation | Source code ]


diffsum.icn: Program to count lines affected by a diff

Usage:  diffsum [file]

Diffsum reads a file containing output from a run of the Unix "diff"
utility.  Diffsum handles either normal diffs or context diffs.  For
each pair of files compared, diffsum reports two numbers:
     1. the number of lines added or changed
     2. the net change in file size
The first of these indicates the magnitude of the changes and the
second the net effect on file size.

[ Full documentation | Source code ]


diffu.icn: Program to show differences in files

This program exercises the dif() procedure, making it act like the
UNIX diff(1) file difference command.

Usage: diffu f1 f2

     3d2
     < c
     7,8c6,7
     < g
     < h
     ---
     > i
     > j

[ Full documentation | Source code ]


diffword.icn: Program to list different words

This program lists all the different words in the input text.
The definition of a "word" is naive.

[ Full documentation | Source code ]


digcol.icn: Program to produce nth column of digit data

This program filters input to produce the nth column of digit date.

[ Full documentation | Source code ]


diskpack.icn: Program to produce packing list for diskettes

This program is designed to produce a list of files to fit onto
diskettes.  It can be adapted to other uses.

This program uses a straightforward, first-fit algorithm.

The options supported are:

    -s i    diskette capacity, default 360000
    -r i    space to reserve on first diskettes, default 0
    -n s    UNIX-style file name specification for files to
            be packed, default "*.lzh"

[ Full documentation | Source code ]


duplfile.icn: Program to find directories with same files

This program lists the file names that occur in more than one
subdirectory and the subdirectories in which the names occur.

This program should be used with caution on large directory
structures.

[ Full documentation | Source code ]


duplproc.icn: Program to find duplicate declarations

Use this if you plan on posting utility procedures suitable for
inclusion in someone's Icon library directories.

duplproc.icn compiles into a program which will search through
every directory in your ILIBS environment variable (and/or in the
directories supplied as arguments to the program).  If it finds any
duplicate procedure or record identifiers, it will report this on
the standard output.

It is important to try to use unique procedure names in programs
you write, especially if you intend to link in some of the routines
contained in the IPL.  Checking for duplicate procedure names has
been somewhat tedious in the past, and many of us (me included)
must be counted as guilty for not checking more thoroughly.  Now,
however, checking should be a breeze.

BUGS:  Duplproc thinks that differently written names for the same
directory are in fact different directories.  Use absolute path
names, and you'll be fine.

[ Full documentation | Source code ]


edscript.icn: Program to produce script for ed(1)

   This program takes specifications for global edits from standard
input and outputs an edit script for the UNIX editor ed to standard output.
Edscript is primarily useful for making complicated literal sub-
stitutions that involve characters that have syntactic meaning to
ed and hence are difficult to enter in ed.

   Each specification begins with a delimiter, followed by a tar-
get string, followed by the delimiter, followed by the replace-
ment string, followed by the delimiter.  For example

        |...|**|
        |****||

specifies the replacement of all occurrences of three consecutive
periods by two asterisks, followed by the deletion of all
occurrences of four consecutive asterisks.  Any character may be
used for the delimiter, but the same character must be used in
all three positions in any specification, and the delimiter char-
acter cannot be used in the target or replacement strings.

Diagnostic:

   Any line that does not have proper delimiter structure is noted
and does not contribute to the edit script.

Reference:

   "A Tutorial Introduction to the UNIX Text Editor", Brian W. Kernighan.
AT&T Bell Laboratories.

[ Full documentation | Source code ]


empg.icn: Program to make expression-evaluation programs

This program produces a program for evaluating Icon expressions.  The
input to this program has three forms, depending on the first character
of each line:

     :       the remainder of the line is an expression to be evaluated
             only once

     %       the remainder of the line is part of a declaration

     #       the remainder of the line is a comment and is ignored

Anything else is an expression to be evaluated in a loop.

For example, the input

# Time record access
%record complex(r, i)
:z := complex(1.0, 3.5)
z.r

produces a program to time z.r in a loop.

[ Full documentation | Source code ]


envelope.icn: Program to address envelopes

This program addresses envelopes on a Postscript or HP-LJ printer,
including barcodes for the zip code.  A line beginning with `#' or
an optional alternate separator can be used to separate multiple
addresses.  The parser will strip the formatting commands from an
address in a troff or LaTeX letter.

usage: envelope [options] < address(es)

Typically, envelope is used from inside an editor.  In emacs, mark
the region of the address and do
     M-| envelope
In vi, put the cursor on the first line of the address and do
     :,+N w !envelope
where N = number-of-lines-in-address.

The barcode algorithm is adapted from a perl script by Todd Merriman
<todd@toolz.uucp>, Dave Buck <dave@dlb.uucp>, and Andy Rabagliati
<andyr@wizzy.com>.

[ Full documentation | Source code ]


evaluate.icn: Program to evaluate Icon expressions

This program evaluates Icon operations given from standard input in
functional form.  It cannot handle nested expressions or control
structures.  See eval.icn for more details.

There is one option:

     -l i    limit on number of results from a generator; default 2 ^ 30

[ Full documentation | Source code ]


extweave.icn: Program to extract weaving specifications from weave file

This program extracts the weaving specifications from a Macintosh
Painter 5 weave file in MacBinary format.  (It might work on Painter 4
weave files; this has not been tested.)

The file is read from standard input.

The output consists of seven lines for each weaving specification in the
file:

     wave name
     warp expression
     warp color expression
     weft expression
     weft color expression
     tie-up
     blank separator

The tie-up is a 64-character string of 1s and 0s in column order. That
is, the first 8 character represent the first column of the tie-up. A
1 indicates selection, 0, non-selection.

This program does not produce the colors for the letters in color
expressions.  We know where they are located but haven't yet figured
out how to match letters to colors.

See Advanced Weaving, a PDF file on the Painter 5 CD-ROM.

[ Full documentation | Source code ]


farb.icn: Program to generate Farberisms

   Dave Farber, co-author of the original SNOBOL programming
language, is noted for his creative use of the English language.
Hence the terms ``farberisms'' and ``to farberate''.  This pro-
gram produces a randomly selected farberism.

Notes: Not all of the farberisms contained in this program were
uttered by the master himself; others have learned to emulate
him.  A few of the farberisms may be objectionable to some per-
sons.  ``I wouldn't marry her with a twenty-foot pole.''

[ Full documentation | Source code ]


farb2.icn: Program to generate Farberisms

   Dave Farber, co-author of the original SNOBOL programming
language, is noted for his creative use of the English language.
Hence the terms ``farberisms'' and ``to farberate''.  This pro-
gram produces a randomly selected farberism.

Notes: Not all of the farberisms contained in this program were
uttered by the master himself; others have learned to emulate
him.  A few of the farberisms may be objectionable to some per-
sons.  ``I wouldn't marry her with a twenty-foot pole.''

[ Full documentation | Source code ]


filecnvt.icn: Program to convert line terminators

   This program copies a text file, converting line terminators. It is
called in the form

     filecnvt [-i s1] [-o s2] infile outfile

The file name "-" is taken to be standard input or output, depending
on its position, although standard input/output has limited usefulness,
since it translates line terminators according the the system
being used.

   The options are:

     -i s1   assume the input file has line termination for the
               system designated by s1. The default is "u".

     -o s2   write the output file with line terminators for the
               system designated by s2. The default is "u".

The designations are:

     d       MS-DOS ("\n\r"); also works for the Atari ST
     m       Macintosh ("\r")
     u       UNIX ("\n"); also works for the Amiga

[ Full documentation | Source code ]


filehtml.icn: Program to create Web page with links to files

The files to be includes are listed on the command line.  There is no
check that the files actually exist.

[ Full documentation | Source code ]


fileprep.icn: Program to prepare file information for IPL indexes

This program creates files used in the construction of indexes for the
Icon program library.

[ Full documentation | Source code ]


fileprnt.icn: Program to display characters in file

   This program reads the file specified as a command-line argument and
writes out a representation of each character in several forms:
hexadecimal, octal, decimal, symbolic, and ASCII code.

   Input is from a named file rather than standard input, so that it
can be opened in untranslated mode.  Otherwise, on some systems, input
is terminated for characters like ^Z.

   Since this program is comparatively slow, it is not suitable
for processing very large files.

   There are several useful extensions that could be added to this program,
including other character representations, an option to skip an initial
portion of the input file, and suppression of long ranges of identical
characters.

[ Full documentation | Source code ]


filerepl.icn: Program to replicate file

This program writes standard input to standard a specified number of
times.  Number of replications is given on command line.

NOTE:  Since the input stream is stored internally, standard input
must be of finite length.

[ Full documentation | Source code ]


filesect.icn: Program to produce section of a file

This program writes the section of the input file starting at a
specified line number and extending a specified number of lines.

The specifications are given as integer command-line arguments; the
first is the starting line, the second is the number of lines.  For
example,

     filesect 20 100 <input >output

copies 100 lines from input to output, starting at line 20 of input.

If the specifications are out of range, the file written is truncated
without comment.

[ Full documentation | Source code ]


filexref.icn: Program to cross-reference files by components

Usage:

            dir dir1 /b /a:d > dirlist
            filexref < dirlist

Note:

            Dir does not preface its results with the parent directory
            - take care!

Options:

   -D       Produce an ascii delimited file
   -h       Exclude hidden files
   -n       Page Length ... must be integer >= 25

[ Full documentation | Source code ]


filtskel.icn: Program skeleton for generic filter

Generic filter skeleton in Icon.

This program is not intended to be used as is -- it serves as a
starting point for creation of filter programs.  Command line
options, file names, and tabbing are handled by the skeleton.  You
need only provide the filtering code.

As it stands, filter.icn simply copies the input file(s) to
standard output.

Multiple files can be specified as arguments, and will be processed
in sequence.  A file name of "-" represents the standard input file.
If there are no arguments, standard input is processed.

[ Full documentation | Source code ]


findstr.icn: Program to find embedded character strings

Utility filter to list character strings embedded in data files (e.g.
object files).

     findstr -options file...

     -l length       minimum string size to be printed (default 3)
     -c chars        a string of characters (besides the standard ASCII
                     printable characters) to be considered part of a
                     string

Icon string escape sequences can be used to specify the -c option.

Multiple files can be specified as arguments, and will be processed
in sequence.

[ Full documentation | Source code ]


findtext.icn: Program to retrieve data from files indexed by idxtext

 See documentation with idxtext.icn, gettext.icn, adjuncts.icn

History:
  (1.1) Tested with DOS, DOS-386, OS/2, ProIcon, UNIX
  (1.2) Use preprocessor include statement instead of link.

[ Full documentation | Source code ]


fixhqx.icn: Program to strip headers from BinHex files

Sometimes Macintosh .hqx files come with commentary before the
BinHex data.  This program strips off the heading material so that
BinHex can be used.

Input comes from standard input and output goes to standard output.

[ Full documentation | Source code ]


fixpath.icn: Program to replace path in a binary file

Usage:  fixpath filename oldpath newpath

Fixpath changes file paths or other strings in a binary file by modifying
the file in place.  Each null-terminated occurrence of "oldpath" is
replaced by "newpath".

If the new path is longer than the old one, a warning is given and the
old path is extended by null characters, which must be matched in the
file for replacement to take place.  This is dangerous in general but
allows repairing an errant fixpath command.

[ Full documentation | Source code ]


fnctab.icn: Program to list function usage

This program processes an MVT token file and tabulates the usage
of functions.

Since function usage cannot be determined completely from static
analysis, the results should be viewed with this limitation in mind.

[ Full documentation | Source code ]


fnctmpl.icn: Program to produce function templates

This program processes the rt.db database for the Icon compiler produced
by rtt and produces procedures for each Icon function to be used by
iftrace.icn.

The data base is expected from standard input.

[ Full documentation | Source code ]


format.icn: Program to word wrap a range of text

Filter to word wrap a range of text.

A number of options are available, including full  justification (see
usage text,  below).  All lines that have the same indentation as the
first  line (or same  comment leading character format if  -c option)
are wrapped.  Other lines are left as is.

This  program  is useful in conjunction with editors  that can invoke
filters on a range of selected text.

The -c option attempts to establish the form of a comment based on the
first  line, then does its best to deal  properly  with the following
lines.   The  types of  comment lines that  are handled  are those in
which  each  line starts with a "comment" character string  (possibly
preceded  by  spaces).  While formatting  comment  lines, text  lines
following the prototype line that don't match the  prototype  but are
flush with  the  left margin are also  formatted  as  comments.  This
feature simplifies  initially entering  lengthy  comments  or  making
major modifications, since  new  text can  be entered without concern
for comment formatting, which will be done automatically later.

[ Full documentation | Source code ]


former.icn: Program to format long string in fixed-length lines

This program takes a single line of input and outputs in in lines
no greater than the number given on the command line (default 80).

[ Full documentation | Source code ]


fract.icn: Program to approximate real number as a fraction

This program produces successive rational approximations to a real
number.

The options supported are:

     -n r    real number to be approximated, default .6180339887498948482
                (see below)

     -l i    limit on number of approximations, default 100 (unlikely to
                be reached).

[ Full documentation | Source code ]


fset.icn: Program to do set operations on file specifications

 The UNIX shell provides for the specification of filenames
using ``wildcards''.  Each wildcard specification may be
thought of as defining a set of names (that is, those that
match the specification).  Fset allows the user to apply the
set operations of intersection, union, and difference to
these filename sets. The resultant list may then be used as
an argument to other shell commands.

Fset's argument is an expression composed of legal UNIX file
specifications, parenthesis, and the following set opera-
tors:

     &&   intersection
     ++   union
     --   difference

Because characters that have special meaning to the shell
occur frequently in the arguments used for fset, it is
advisable to quote the arguments consistently.

The use of fset is illustrated by the following examples:

     fset 'g*--*.icn'

produces the list (set) of filenames for files beginning
with g, excluding those ending with .icn.

Similarly,

     fset '*'

produces all files in the current directory excluding the .
and .. files.

     fset '((*--*.icn)++c*)'
and

     fset '(*--*.icn)++c*'

produces the complement of all filenames ending with .icn in
addition to all filenames beginning with c.

     fset '(((c? && c*)))'

is a redundant, but legal, specification for all two-
character filenames that begin with c, while

     fset '.*'

produces the set of filenames for all hidden files, exclud-
ing the . and ..  files.

Limitations:

Multiple command line arguments, formed by omitting the
quotes around the file set expression, are permitted.  Their
use is limited, however, since parentheses do not get past
the shell's command-line expansion.

Almost any legal file specification will work when enclosed
in quotes except that the simple grammar that is used cannot
handle blanks adjacent to parentheses.

File names that begin or end in ``questionable'' characters
such as *, ?, +, -, and &, probably will not work.

A file specification that, when interpreted by the shell,
produces no matching filename will be placed (unchanged) in
the result.

[ Full documentation | Source code ]


fuzz.icn: Program to perform fuzzy pattern matching

   This program illustrates "fuzzy" string pattern matching.  The result
of matching s and t is a number between 0 and 1 which is based on
counting matching pairs of characters in increasingly long substrings
of s and t.  Characters may be weighted differently, and the reverse
tally may be given a negative bias.

[ Full documentation | Source code ]


gcomp.icn: Program to produce complement of file specification

   This program produces a list of the files in the current directory
that do not appear among the arguments.  For example,

     gcomp *.c

produces a list of files in the current directory that do
not end in .c.  As another example, to remove all the files
in the current directory that do not match Makefile, *.c, and *.h
the following can be used:

     rm `gcomp Makefile *.c *.h`

The files . and .. are not included in the output, but other
`dot files' are.

[ Full documentation | Source code ]


geddump.icn: Program to dump contents of GEDCOM file

usage:  geddump [file]

This program prints the genealogical information contained
in a GEDCOM file.  Individuals are printed alphabetically,
with sequence numbers to assist cross-referencing.

Marriages are noted for both partners.  Children are listed
under the father, or under the mother if no father is known.

[ Full documentation | Source code ]


gediff.icn: Program to "diff" for use with ged

Program to produce diff output in a format for use with ged's
"FindFileAndLine" (esc-S) command.  It causes the "diffed" files
to be open in the editor with the differing portions selected.

[ Full documentation | Source code ]


gener.icn: Program to generate sequence from Icon expression

This program takes an Icon expression is given on the command line, and
writes its results to standard output.  Watch for syntactic problems.

[ Full documentation | Source code ]


genfile.icn: Program to generate sequence from Icon expression in file

This program writes the results of an Icon expression given in the file
named on the command line.

[ Full documentation | Source code ]


genqueen.icn: Program to solve arbitrary-size n-queens problem

This program solve the non-attacking n-queens problem for (square) boards
of arbitrary size.  The problem consists of placing chess queens on an
n-by-n grid such that no queen is in the same row, column, or diagonal as
any other queen.  The output is each of the solution boards; rotations
not considered equal.  An example of the output for n:

    -----------------
    |Q| | | | | | | |
    -----------------
    | | | | | | |Q| |
    -----------------
    | | | | |Q| | | |
    -----------------
    | | | | | | | |Q|
    -----------------
    | |Q| | | | | | |
    -----------------
    | | | |Q| | | | |
    -----------------
    | | | | | |Q| | |
    -----------------
    | | |Q| | | | | |
    -----------------

Usage: genqueen n
where n is the number of rows / columns in the board.  The default for n
is 6.

[ Full documentation | Source code ]


getcol.icn: Program to extract column from data

This program extracts a column from multi-column data.

The supported options are:

    -n i    column number, default 1
    -c s    column-separation characters, default ' \t'

[ Full documentation | Source code ]


getlines.icn: Program to extract lines from a file

This program is designed to extract a few specified lines from a file.
The line numbers are given on the command line, the file is read from
standard input and the extracted lines are written to standard output
as in

     getlines 46 23 119 <infile >outfile

which writes lines 23, 46, and 119 of infile (if it contains that many
lines) to outfile.

Line numbers do not have to be given in order.  Numbers less than 1 are
ignored, but a nonnumerical argument is treated as an error.

[ Full documentation | Source code ]


gftrace.icn: Program for generating function tracing procedures

   This program writes a set of procedures to standard output.  Those
procedures can be linked with an Icon program to enable the tracing of
calls to built-in functions.  See the comments in the generated code
for details.

   The set of generated functions reflects the built-in functions of
the version of Icon under which this generator is run.

[ Full documentation | Source code ]


graphdem.icn: Program to demonstrate simple bar graphics

graph.icn: simple bar graphics package with two demo applications:
  1. display the 4 most frequently used characters in a string.
  2. display the fibonacci numbers

[ Full documentation | Source code ]


grpsort.icn: Program to sort groups of lines

   This program sorts input containing ``records'' defined to be
groups of consecutive lines. Output is written to standard out-
put.  Each input record is separated by one or more repetitions
of a demarcation line (a line beginning with the separator
string).  The first line of each record is used as the key.

   If no separator string is specified on the command line, the
default is the empty string. Because all input lines are trimmed
of whitespace (blanks and tabs), empty lines are default demarca-
tion lines. The separator string specified can be an initial sub-
string of the string used to demarcate lines, in which case the
resulting partition of the input file may be different from a
partition created using the entire demarcation string.

   The -o option sorts the input file but does not produce the
sorted records.  Instead it lists the keys (in sorted order) and
line numbers defining the extent of the record associated with
each key.

   The use of grpsort is illustrated by the following examples.
The command

        grpsort "catscats" <x >y

sorts the file x, whose records are separated by lines containing
the string "catscats", into the file y placing a single line of
"catscats" between each output record. Similarly, the command

        grpsort "cats" <x >y

sorts the file x as before but assumes that any line beginning
with the string "cats" delimits a new record. This may or may not
divide the lines of the input file into a number of records dif-
ferent from the previous example.  In any case, the output
records will be separated by a single line of "cats".  Another
example is

        grpsort -o <bibliography >bibkeys

which sorts the file bibliography and produces a sorted list of
the keys and the extents of the associated records in bibkeys.
Each output key line is of the form:

        [s-e] key

where

        s     is the line number of the key line
        e     is the line number of the last line
        key   is the actual key of the record

[ Full documentation | Source code ]


hcal4unx.icn: Program for Jewish/Civil calendar in UNIX

This work is respectfully devoted to the authors of two books
consulted with much profit: "A Guide to the Solar-Lunar Calendar"
by B. Elihu Rothblatt published by our sister Hebrew Dept. in
Madison, Wis., and "Kiddush HaHodesh" by Rabbenu Moses ben Maimon,
on whom be peace.

The Jewish year harmonizes the solar and lunar cycle, using the
19-year cycle of Meton (c. 432 BCE). It corrects so that certain
dates shall not fall on certain days for religious convenience. The
Jewish year has six possible lengths, 353, 354, 355, 383, 384, and
385 days, according to day and time of new year lunation and
position in Metonic cycle.  Time figures from 6pm previous night.
The lunation of year 1 is calculated to be on a Monday (our Sunday
night) at ll:11:20pm. Our data table begins with a hypothetical
year 0, corresponding to 3762 B.C.E.  Calculations in this program
are figured in the ancient Babylonian unit of halaqim "parts" of
the hour = 1/1080 hour.

Startup syntax is simply hebcalen [date], where date is a year
specification of the form 5750 for a Jewish year, +1990 or 1990AD
or 1990CE or -1990 or 1990BC or 1990BCE for a civil year.

[ Full documentation | Source code ]


headicon.icn: Program to add header to Icon program

This program prepends a standard header to an Icon program.  It does not
check to see if the program already has a header.

The first command-line argument is taken as the base
name of the file; default "foo".  The second command-line argument is
taken as the author; the default is "Ralph E. Griswold" -- with minor
apologies, I use this program a lot; personalize it for your own
use.

The new file is brought up in the vi editor.

The file skeleton.icn must be accessible via dopen().

[ Full documentation | Source code ]


hebcalen.icn: Program for combination Jewish/Civil calendar

This work is respectfully devoted to the authors of two books
consulted with much profit: "A Guide to the Solar-Lunar Calendar"
by B. Elihu Rothblatt published by our sister Hebrew Dept. in
Madison, Wis., and "Kiddush HaHodesh" by Rabbenu Moses ben Maimon,
on whom be peace.

The Jewish year harmonizes the solar and lunar cycle, using the
19-year cycle of Meton (c. 432 BCE). It corrects so that certain
dates shall not fall on certain days for religious convenience. The
Jewish year has six possible lengths, 353, 354, 355, 383, 384, and
385 days, according to day and time of new year lunation and
position in Metonic cycle.  Time figures from 6pm previous night.
The lunation of year 1 is calculated to be on a Monday (our Sunday
night) at ll:11:20pm. Our data table begins with a hypothetical
year 0, corresponding to 3762 B.C.E.  Calculations in this program
are figured in the ancient Babylonian unit of halaqim "parts" of
the hour = 1/1080 hour.

Startup syntax is simply hebcalen [date], where date is a year
specification of the form 5750 for a Jewish year, +1990 or 1990AD
or 1990CE or -1990 or 1990BC or 1990BCE for a civil year.

[ Full documentation | Source code ]


hebeng.icn: Program to print mixed Hebrew/English text

This program is written in ProIcon for the Macintosh computer. Alan D. Corre
August 1991. It takes input in a transcription of Hebrew which represents
current pronunciation adequately but mimics the peculiarities of Hebrew
spelling. Here are some sentences from the beginning of Agnon's story
"Friendship": marat qliyngel 'i$ah mefursemet haytah umenahelet beyt sefer
haytah qowdem liymowt hamilHamah. mi$eni$tanu sidrey ha`owlam,neHtexah
migdulatah..wexol miy $eyac'u low mowniyTiyn ba`owlam haytah mitqarevet
'eclow weyowce't wenixneset leveytow" The letter sin is represented by the
German ess-zed which is alt-s on the Mac and cannot be represented here.
The tilde (~)toggles between English and Hebrew, so the word "bar" will be
the English word "bar" or the Hebrew beyt-rey$ according to the current
mode of the program. Finals are inserted automatically. Justification
both ways occurs unless the program detects a blank or empty line, in
which case the previous line is not justified.
Since I took out non-ASCII chars, and have not rechecked that this
works with the corresponding octal chars, there could be some slips in
this text.

[ Full documentation | Source code ]


hotedit.icn: Program to edit a Mosaic hotlist

===> IMPORTANT NOTE:  This program was written for "NCSA Mosaic 2.4"
===> and is incompatible with the current version of Mosaic.

Hotedit makes it easy to edit the "hotlist" used with NCSA Mosaic,
a program for grazing the Wide World Web (WWW).  The Mosaic hotlist
is a text file, and it can be edited directly, but this is difficult
and error-prone.  Pairs of lines must be kept together, and the long
"Uniform Record Locator" (URL) lines make it hard to pick out the
title lines, which are of more interest.

Hotedit works by extracting the titles, bringing up an editor of the
user's choice, then processing the results when the editor exits.
The user can reorder, retitle, or delete lines; adding new entries
is best done within NCSA Mosaic.  It is vital that any editing
preserve the three-digit number at the front of each line; hotedit
uses this to reconnect the titles with the corresponding URLs.

The editor is determined by the environment variable VISUAL (or, if
that is missing, EDITOR).  The hotlist file is assumed to be in the
usual place, $HOME/.mosaic-hotlist-default.  Because not all editors
return a reasonable exit status, the hotlist is *always* rewritten;
the previous edition is saved in $HOME/.mosaic-hotlist-backup.

Hotedit shouldn't be run while NCSA Mosaic is running; when Mosaic
exits, it is likely to overwrite the edited hotlist.

[ Full documentation | Source code ]


hr.icn: Program to play horse-race game

This program implements a horse-race game.

[ Full documentation | Source code ]


htget.icn: Program to get Web file using HTTP protocol

Htget retrieves the raw text of a file from the world wide web using
HTTP protocol.  (Other protocols such as FTP are not supported.)

usage:  htget [-h | -b] URL

The URL may be given with or without the "http://" prefix.

If -h is given, a HEAD request is sent, requesting only information
instead of the complete file.

If -b is given, the header is stripped and the body is copied
in binary mode.

[ Full documentation | Source code ]


htprep.icn: Program to prepare HTML files

usage:  htprep [file]

Htprep is a filter for preparing HTML files (used, e.g., by Mosaic)
from a simpler and less error-prone input language.

The following transformations are applied:

     input           output
     ------------    ------------
     {}
     {!comment}      <!--comment-->
     {tag}           <tag>
     {tag ... }      <tag> ... <\tag>
       att=val...      att="val"...
     {@url ...       <a href="url" ...
     {:lbl ...       <a name="lbl" ...

Any input character can be preceded by a backslash (\) to prevent
special interpretation by htprep.

Output is normally to stdout, but the command
     {divert fname}
redirects output to the named file.  This can be used to produce
multiple related output files from a single input file.

[ Full documentation | Source code ]


huffstuf.icn: Program for huffman coding

An odd assortment of tools that lets me compress text using an
Iconish version of a generic Huffman algorithm.

[ Full documentation | Source code ]


hufftab.icn: Program to compute Huffman state transitions

   Each input line should be a string of 0s & 1s followed by a value
field.  Output is a list of items in a form suitable for inclusion
by a C program as initialization for an array.  Each pair of items
indicates the action to be taken on receipt of a 0 or 1 bit from the
corresponding state; this is either a state number if more decoding
is needed or the value field from the input if not.  State 0 is the
initial state;  0 is output only for undefined states.  States are
numbered by two to facilitate use of a one-dimensional array.

sample input:               corresponding output:
    00 a                        /*  0 */  2, c, a, 4, 0, b,
    011 b
    1 c                     [new line started every 10 entries]

Interpretation:
    from state 0,  input=0 => go to state 2,  input=1 => return c
    from state 2,  input=0 => return a,  input=1 => go to state 4
    from state 4,  input=0 => undefined,  input=1 => return b

[ Full documentation | Source code ]


ibar.icn: Program to equalize comment bars in Icon programs

This program replaces comment bars in Icon programs by bars 76 characters
long -- the program library standard.

[ Full documentation | Source code ]


ibrow.icn: Program to browse Icon files for declarations

Usage: ibrow [<Icon source file name>...]

If no source file names are provided on the command line, all *.icn
files in the current directory are browsed.

The program facilitates browsing of Icon programs.  It was originally
written to browse the Icon Program Library, for which purpose it
serves quite well.  The user interface is self-explanatory -- just
remember to use "?" for help if you're confused.

[ Full documentation | Source code ]


icalc.icn: Program to simulate infix desk calculator

This is a simple infix calculator with control structures and
  compound statements.  It illustrates a technique that can be
  easily used in Icon to greatly reduce the performance cost
  associated with recursive-descent parsing with backtracking.
  There are numerous improvements and enhancements that can be
  made.

Features include:

      - integer and real value arithmetic
      - variables
      - function calls to Icon functions
      - strings allowed as function arguments
      - unary operators:
            + (absolute value), - (negation)
      - assignment:
            :=
      - binary operators:
            +,-,*,/,%,^,
      - relational operators:
            =, !=, <, <=, >, >=
               (all return 1 for true and 0 for false)
      - compound statements in curly braces with semicolon separators
      - if-then and if-then-else
      - while-do
      - limited form of multiline input

The grammar at the start of the 'parser' proper provides more
  details.

Normally, the input is processed one line at a time, in calculator
  fashion.  However, compound statements can be continued across
  line boundaries.

Examples:

  Here is a simple input:

      {
      a := 10;
      while a >= 0 do {
         write(a);
         a := a - 1
         };
      write("Blastoff")
      }

   (execution is delayed until entire compound statement is entered)

  Another one:

  write(pi := 3.14159)
  write(sin(pi/2))

   (execution done as each line is entered)

[ Full documentation | Source code ]


icalls.icn: Program to tabulate Icon calls

This program processes trace output and tabulates calls of procedures

[ Full documentation | Source code ]


icn2c.icn: Program to assist Icon-to-C porting

Filter to do some mundane aspects of conversion of Icon to C.

- Reformats comments
- Reformats line-continued strings
- Changes := to =
- Reformats procedure declarations
- Changes end to "}"

[ Full documentation | Source code ]


icontent.icn: Program to list Icon procedures

Builds a list, in Icon comment format, of procedures and records
in an Icon source file.

Multiple files can be specified as arguments, and will be processed
in sequence.  A file name of "-" represents the standard input file.
If there are no arguments, standard input is processed.

usage: icontent <options> <Icon source file>...
     options:        -s      sort names alphabetically (default is in
                             order of occurrence)
                     -l      list in single column (default is to list
                             in multiple columns)

[ Full documentation | Source code ]


icvt.icn: Program for ASCII/EBCDIC program conversion

This program converts Icon programs from ASCII syntax to EBCDIC syntax
or vice versa. The option -a converts to ASCII, while the option
-e converts to EBCDIC. The program given in standard input is written
in converted form to standard output.

[ Full documentation | Source code ]


idepth.icn: Program to report maximum recursion depth

This program processes trace output and reports the maximum depth of
recursion.

[ Full documentation | Source code ]


idxtext.icn: Program for creating indexed text-base

    idxtext turns a file associated with gettext() routine into an
indexed text-base.  Though gettext() will work fine with files
that haven't been indexed via idxtext(), access is faster if the
indexing is done if the file is, say, over 10k (on my system the
crossover point is actually about 5k).

    Usage is simply "idxtext [-a] file1 [file2 [...]]," where file1,
file2, etc are the names of gettext-format files that are to be
(re-)indexed.  The -a flag tells idxtext to abort if an index file
already exists.

    Indexed files have a very simple format: keyname delimiter offset
[delimiter offset [etc.]]\n.  The first line of the index file is a
pointer to the last indexed byte of the text-base file it indexes.

BUGS: Index files are too large.  Also, I've yet to find a portable
way of creating unique index names that are capable of being
uniquely identified with their original text file.  It might be
sensible to hard code the name into the index.  The chances of a
conflict seem remote enough that I haven't bothered.  If you're
worried, use the -a flag. (RLG)

[ Full documentation | Source code ]


ifilter.icn: Program to filter lines of file

This program applies the operation given as a command-line argument
to each line of standard input, writing out the results.  For example,

     ifilter reverse <foo

writes out the lines of foo reversed end-for-end.

Trailing arguments can be given on the command line, as in

     ifilter right 10 0 <foo         # right(*, "10", "0")
     ifilter "%" 11 <foo             # * % "11"

The modules strings and numbers are linked to provide access to the
procedures they contain.  Except for these and operators and (built-in)
functions, this program needs to be linked with procedures to be
used with it.

The following options are supported:

     -a i    argument position for strings read in; default 1
     -o i    resolution of ambiguous operator string names, 1 for unary, 2
               for binary; default 2
     -l i    limit on generation, with nonpositive indicating
               no limitation; default 1

[ Full documentation | Source code ]


ifncsgen.icn: Program to generate procedure wrappers for functions

This program generates a procedure for every (built-in) function
that calls the function.

[ Full documentation | Source code ]


igrep.icn: Program for string search similar to egrep

Program to emulate UNIX egrep, but using the enhanced regular
expressions supported by regexp.icn.  Options supported are nearly
identical to those supported by egrep (no -b:  print disk block
number).  There is one additional option, -E, to allow Icon-type
(hence C-type) string escape sequences in the pattern string.
BEWARE:  when -E is used, backslashes that are meant to be processed
in the regular expression context must be doubled.  The following
patterns are equivalent:

 without -E: '\bFred\b'
 with    -E: '\\bFred\\b'

To enable the -D option (intended mainly for debugging), the Icon
Program Library file "ximage" must be linked with this program.

[ Full documentation | Source code ]


iheader.icn: Program to list Icon program library headers

This program lists the headers of Icon programs whose file names are
given on the command line.  It complains if the header does not start
correctly but otherwise does not check the syntax of what follows.

[ Full documentation | Source code ]


ihelp.icn: Program to give on-line help for Icon

ihelp -- Program to display "help" information

     ihelp [-f helpfile] [item] [keyword ...]

The optional item name specifies the section of the help file which
is to be displayed.  If no item name is specified a default section
will be displayed, which usually lists the help items that are
available.  An initial substring of the item name that differentiates
it from other items is sufficient.

If keyword(s) are specified, then only lines that contain all of the
keywords, in any order, are displayed.  The keywords do not have to
correspond to whole words in the help text; only to text fragments.

All item name and keyword matches are case independent.

The help file name is taken from environment variable "HELPFILE".  If
HELPFILE is not in the environment, file "help" in the current
directory is used.  A help file name specified in the -f option
overrides.

The help files are formatted as follows:

     default text lines
     -
     one
     item "one" text lines
     -
     two
     item "two" text lines
     ...

Sections are separated by lines containing a single "-".  Item names
are the first line following a separator line.

[ Full documentation | Source code ]


iidecode.icn: Program to decode text in style of uudecode

This is an Icon port of the UNIX/C uudecode utility.  Since
uudecode is publicly distributable BSD code, I simply grabbed a
copy, and rewrote it in Icon.  The only basic functional changes I
made to the program were:  (1) To simplify the notion of file mode
(everything is encoded with 0644 permissions), and (2) to add a
command-line switch for xxencoded files (similar to uuencoded
files, but capable of passing unscathed through non-ASCII EBCDIC
sites).

       usage:  iidecode [infile] [-x]

Usage is compatible with that of the UNIX uudecode command, i.e. a
first (optional) argument gives the name the file to be decoded.
If this is omitted, iidecode just uses the standard input.  The -x
switch (peculiar to iidecode) forces use of the the xxdecoding
algorithm.  If you try to decode an xxencoded file without speci-
-x on the command line, iidecode will try to forge ahead anyway.
If it thinks you've made a mistake, iidecode will inform you after
the decode is finished.


FIXES: Speeded up substantially (more than twice as fast on my
machine) by using a more icon-ish algorithm.  We decode in two
steps:

1)   The coded characters are mapped to "small bytes",
     each with 2 zero high bits, i.e. <<= "\x3F".
2)   We then 'pack' the small bytes by taking groups of 4 small bytes
     (each with 2 zero high bits and 6 data bits) and packing
     the data bits into groups of 3 bytes.

There are numerous advantages to this approach.  The icon map
function is much faster than the 'C'-ish alternatives.  We can
process things one line at a time. Also, the different decoding
mechanisms (old BSD, new BSD, xxdecode) can be produces by simply
using different map parameters.

[ Full documentation | Source code ]


iiencode.icn: Program to encode text in the style of uuencode

This is an Icon port of the UNIX/C uuencode utility.  Since
uuencode is publicly distributable BSD code, I simply grabbed a
copy, and rewrote it in Icon.  The only basic functional changes I
made to the program were:  (1) To simplify the notion of file mode
(everything is encoded with 0644 permissions), and (2) to add sup-
port for xxencode format (which will generally pass unscathed even
through EBCDIC sites).

Iiencode's usage is compatible with that of the UNIX uuencode
command, i.e. a first (optional) argument gives the name the file
to be encoded.  If this is omitted, iiencode just uses the standard
input.  The second argument specifies the name the encoded file
should be given when it is ultimately decoded.

Extensions to the base uuencode command options include -x and -o.
An -x tells iiencode to use xxencode (rather than uuencode) format.
Option -o causes the following argument to be used as the file
iiencode is to write its output to (the default is &output).  Note
that, on systems with newline translation (e.g. MS-DOS), the -o
argument should always be used.

  iiencode [infile] [-x] remote-filename [-o output-filename]


FIXES: Speeded up substantially (more than twice as fast on my
machine) by using a more icon-ish algorithm.  We encode in two
steps:

1)   We first "unpack" the bytes by taking groups of 3 bytes (24
     bits) and spreading them out by inserting two 0 bits before
     every block of 6 bits.  The result is that each group of 3
     bytes is unpacked to 4 "small bytes", each <<= "\x3F".
2)   The unpacked bytes are mapped to the coded line by using the
     Icon map function.

There are numerous advantages to this approach.  The Icon map
function is much faster than the 'C'-ish alternatives.  We can
process the file one line at a time. Also, the different encoding
mechanisms (old BSD, new BSD, xxencode) can be produces by simply
using different map parameters.

[ Full documentation | Source code ]


ilnkxref.icn: Program to produce Icon link cross reference

Utility to create cross reference of library files used in Icon
programs (i.e., those files named in "link" declarations).

     ilnkxref [-options] <icon source file>...

     options:

             -p      sort by "popularity"
             -v      report progress information

[ Full documentation | Source code ]


ilump.icn: Program to lump linked Icon