home *** CD-ROM | disk | FTP | other *** search
- #
- # Program to arrange file names into multiple columns.
- #
- # 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"} | col
- #
- # The output from the Files command is "piped" to the "col" program
- # (this program), which prints its list in the current window.
- #
- # By putting both the "lc" command file and the "col" 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.
-
- procedure main()
- local entries,entry,max,cols,width,lines,i,j,t
- repeat {
- entries := []
- max := 0
- while entry := "" ~== read() do {
- max <:= *entry
- put(entries,entry)
- }
- cols := 80 / (max + 2)
- width := 80 / cols
- lines := (*entries + cols - 1) / cols
- every i := 1 to lines do {
- t := ""
- every j := 0 to cols - 1 do
- t ||:= left(entries[i + j * lines],width)
- write(trim(t))
- }
- write("\n",read()) | break
- }
- end
-