home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 310.lha / ColumnSet / column_set.MOD < prev    next >
Text File  |  1980-12-10  |  16KB  |  672 lines

  1. MODULE column_set;
  2.  
  3. (* Copyright 1989 by Kent Paul Dolan, USENet: xanthian@well.sf.ca.us          *
  4.  
  5. (* Use it as you wish, but leave me a little credit somewhere in the result!  *
  6.  
  7.  
  8. (* Developed with BENCHMARK Modula-2 from Avante-Garde Software               *
  9.  
  10.  
  11. (* Purpose: to lay out "words" from a file of one word per line in as many    *
  12.  
  13. (* columns as will fit across the page with at least one space between        *
  14.  
  15. (* columns.  Command usage is described further down in the code.  This code  *
  16.  
  17. (* was written to provide a filter in a script for making the output of the   *
  18.  
  19. (* AmigaDOS "list lformat="%S" command look like the Unix "ls" output, but    *
  20.  
  21. (* looks useful as an independent command, as well.                           *
  22.  
  23.  
  24. (* It is a modest attempt at mixing a Unix and an AmigaDOS command format in  *
  25.  
  26. (* a small utility, while reasonably bullet-proofing the routine from command *
  27.  
  28. (* line errors or i/o problems.  The working guts of the program, without     *
  29.  
  30. (* the frills, takes up 1/3 the source and 1/2 the runtime space; this is an  *
  31.  
  32. (* exercise in doing the job "right", for the fun of it.   Kent.              *
  33.  
  34.  
  35. FROM System IMPORT argc, argv, StdInput, StdOutput;
  36.  
  37. FROM InOut IMPORT WriteString, WriteInt, WriteLn, Write, Read, OpenInputFile,
  38.                   OpenOutputFile, Done, CloseInput, CloseOutput, EOL;
  39.  
  40. IMPORT Terminal;
  41.  
  42. FROM Terminal IMPORT eof;
  43.  
  44. FROM FileSystem IMPORT Response, File, Lookup, Close, Delete, ReadChar,
  45.                        WriteChar;
  46.  
  47. FROM Strings IMPORT CompareStringCAP, LocateChar, CopyString, Relation;
  48.  
  49. CONST
  50.   DefaultWindowWidth = 77;
  51.   TempFileName = "T:column_set.temp";
  52.  
  53. TYPE
  54.   CommandLineParam = ARRAY [0..255] OF CHAR;
  55.   
  56. VAR
  57.   Ch:             CHAR;
  58.  
  59.   InFile,
  60.   OutFile:        CommandLineParam;
  61.  
  62.   MaxLength, 
  63.   WindowWidth,
  64.   ThisLength,
  65.   MaxColumns,
  66.   NumColumns,
  67.   ThisColumn,
  68.   NumSpaces,
  69.   I:              INTEGER;
  70.  
  71.   TempFile:       File;
  72.  
  73.   UsingStdInput,
  74.   UsingStdOutput,
  75.   WentOK:         BOOLEAN;
  76.  
  77. (*
  78. ** Usage: column_set [[FROM | -i] infile] [[TO | -o] outfile] [[WIDTH | -w] nn]
  79. **        [[MAXCOL | -m] mm]
  80. **
  81. ** infile is the input file, one "word" per line;
  82. ** outfile is the output file, with the same words in the same order laid out
  83. ** in columns evenly across the page or screen;
  84. ** width is the number of character positions across the screen or page;
  85. ** default is 77 to fit a standard AmigaDOS window;
  86. ** maxcol limits the number of columns of words which will be set across the
  87. ** page to less than the maximum possible; default is (width+1)/2;
  88. **
  89. ** where infile, outfile, width and maxcol are positional parameters unless the
  90. ** keywords are present.  If no infile is given, standard input is used, and
  91. ** a temporary file "column_set.temp" is created and deleted to allow a second
  92. ** pass over the input data.  If an infile is given, it is closed and reopened
  93. ** for the second pass over the data.  If no outfile is given, standard output
  94. ** is used.
  95. *)
  96.  
  97. PROCEDURE usage;
  98. BEGIN
  99.   WriteLn;
  100.   WriteString
  101.   ("Usage: column_set [FROM | -i] infile [TO | -o] outfile [WIDTH | -w] ww");
  102.   WriteLn;
  103.   WriteString
  104.   ("       [MAXCOL | -m] mm]");
  105.   WriteLn;
  106.   WriteString
  107.   ("   or: column_set < infile > outfile [{WIDTH | -w} ww] [{MAXCOL | -m} mm]")
  108.  
  109.   WriteLn;
  110.   WriteString
  111.   ("   or: column_set [(WIDTH | -w} ww] [{MAXCOL | -m} mm] infile outfile");
  112.   WriteLn;
  113.   WriteString
  114.   ("or other likely combinations; infile, outfile, ww, and mm are positional");
  115.   WriteLn;
  116.   WriteString
  117.   ("without keywords, position independent with keywords, and mixes are read");
  118.   WriteLn;
  119.   WriteString
  120.   ("by trying to pick off first the keyword parmameters, then the missing");
  121.   WriteLn;
  122.   WriteString
  123.   ("positional parameters in order from what is left over.");
  124.   WriteLn;
  125.   WriteString
  126.   ("'Infile' is the input file, expected to contain one 'word' per line;");
  127.   WriteLn;
  128.   WriteString
  129.   ("'outfile' is the output file, which will contain the same 'words' in the");
  130.   WriteLn;
  131.   WriteString
  132.   ("same order laid out in as many even columns as will fit across the");
  133.   WriteLn;
  134.   WriteString
  135.   ("page or screen; 'ww' is the width of the screen or page in character");
  136.   WriteLn;
  137.   WriteString
  138.   ("positions; 'mm' is the most 'words' the user wants per line, to limit");
  139.   WriteLn;
  140.   WriteString
  141.   ("them below the most possible in case a sparser layout is desired.");
  142.   WriteLn;
  143.   WriteString
  144.   ("If infile and/or outfile are not specified, they default to standard");
  145.   WriteLn;
  146.   WriteString
  147.   ("input and output; width (ww) defaults to 77 columns to match the");
  148.   WriteLn;
  149.   WriteString
  150.   ("AmigaShell window, and maxcol (mm) defaults to (width+1)/2.");
  151.   WriteLn;
  152.   WriteString
  153.   ("                     /s/  Kent Paul Dolan, USENet: xanthian@well.sf.ca.us")
  154.  
  155.   WriteLn;
  156.   WriteLn;
  157.   RETURN;
  158. END usage;
  159.  
  160. PROCEDURE getcmdline
  161.           (VAR infile, outfile: ARRAY OF CHAR;
  162.            VAR width: INTEGER; VAR maxcol: INTEGER): BOOLEAN;
  163. VAR
  164.   J, MyArgc, UnusedArgs: INTEGER;
  165.   Unused: ARRAY [0..15] OF INTEGER;
  166.  
  167. PROCEDURE getwidth(VAR width: INTEGER; token: ARRAY OF CHAR): BOOLEAN; 
  168. VAR
  169.   CharIndex, DigitValue: INTEGER;
  170.  
  171. BEGIN
  172.   CharIndex := 0;
  173. (*
  174.   WriteString(argv^[J+1]^); WriteLn;
  175. *)
  176.   WHILE (ORD(token[CharIndex]) <> 0) DO
  177.     DigitValue := LocateChar("0123456789",token[CharIndex],0,9);
  178.     IF ( DigitValue = -1 ) THEN
  179.       WriteString("column_set: Error -- non-digit in width parameter");
  180.       WriteLn;
  181.       RETURN FALSE;
  182.     ELSE
  183.       width := 10 * width + DigitValue;
  184.     END;
  185.     CharIndex := CharIndex + 1;
  186.   END;
  187.   RETURN TRUE;
  188. END getwidth;
  189.  
  190. PROCEDURE getmaxcol(VAR maxcol: INTEGER; token: ARRAY OF CHAR): BOOLEAN; 
  191. VAR
  192.   CharIndex, DigitValue: INTEGER;
  193.  
  194. BEGIN
  195.   CharIndex := 0;
  196. (*
  197.   WriteString(argv^[J+1]^); WriteLn;
  198. *)
  199.   WHILE (ORD(token[CharIndex]) <> 0) DO
  200.     DigitValue := LocateChar("0123456789",token[CharIndex],0,9);
  201.     IF ( DigitValue = -1 ) THEN
  202.       WriteString("column_set: Error -- non-digit in maxcol parameter");
  203.       WriteLn;
  204.       RETURN FALSE;
  205.     ELSE
  206.       maxcol := 10 * maxcol + DigitValue;
  207.     END;
  208.     CharIndex := CharIndex + 1;
  209.   END;
  210.   RETURN TRUE;
  211. END getmaxcol;
  212.  
  213. BEGIN (* getcmdline *)
  214.   
  215.   CopyString(infile,"");
  216.   CopyString(outfile,"");
  217.   width := 0;
  218.   UnusedArgs := 0;
  219.   
  220.   FOR J := 0 TO 15 BY 1 DO
  221.     Unused[J] := 0;
  222.   END;
  223.  
  224.   MyArgc := argc;
  225. (*
  226.   WriteString("MyArgc"); WriteInt(MyArgc,4); WriteLn;
  227. *)
  228.   (* Pull out any keyword arguments from the command line: *)
  229.   J := 1;
  230.   WHILE (J < MyArgc) DO
  231. (*
  232.     WriteString(argv^[J]^);
  233. *)
  234.     IF 
  235.     (
  236.       ( CompareStringCAP( argv^[J]^ , "-i" ) = equal )
  237.       OR
  238.       ( CompareStringCAP( argv^[J]^ , "FROM" ) = equal )
  239.     ) THEN
  240.       IF ( J + 1 >= MyArgc ) THEN
  241.         WriteString
  242. ("column_set: Error -- '-i' or 'FROM' was last argument on command line");
  243.         WriteLn;
  244.        RETURN FALSE;
  245.       ELSE
  246.         CopyString(infile,argv^[J+1]^);
  247. (*
  248.         WriteString(argv^[J+1]^); WriteLn;
  249. *)
  250.         J := J + 2;
  251.       END;
  252.     ELSIF
  253.     (
  254.       ( CompareStringCAP( argv^[J]^ , "-o" ) = equal )
  255.       OR
  256.       ( CompareStringCAP( argv^[J]^ , "TO" ) = equal )
  257.     ) THEN
  258.       IF ( J + 1 >= MyArgc ) THEN
  259.         WriteString
  260. ("column_set: Error -- '-o' or 'TO' was last argument on command line");
  261.         WriteLn;
  262.        RETURN FALSE;
  263.       ELSE
  264.         CopyString(outfile,argv^[J+1]^);
  265. (*
  266.         WriteString(argv^[J+1]^); WriteLn;
  267. *)
  268.         J := J + 2;
  269.       END;
  270.     ELSIF
  271.     (
  272.       ( CompareStringCAP( argv^[J]^ , "-w" ) = equal )
  273.       OR
  274.       ( CompareStringCAP( argv^[J]^ , "WIDTH" ) = equal )
  275.     ) THEN
  276.       IF ( J + 1 >= MyArgc ) THEN
  277.         WriteString
  278. ("column_set: Error -- '-w' or 'WIDTH' was last argument on command line");
  279.         WriteLn;
  280.        RETURN FALSE;
  281.       ELSE
  282.         width := 0;
  283.         IF ( NOT getwidth(width,argv^[J + 1]^) ) THEN
  284.           RETURN FALSE;
  285.         END;
  286.        J := J + 2;
  287.       END;
  288.     ELSIF
  289.     (
  290.       ( CompareStringCAP( argv^[J]^ , "-m" ) = equal )
  291.       OR
  292.       ( CompareStringCAP( argv^[J]^ , "MAXCOL" ) = equal )
  293.     ) THEN
  294.       IF ( J + 1 >= MyArgc ) THEN
  295.         WriteString
  296. ("column_set: Error -- '-m' or 'MAXCOL' was last argument on command line");
  297.         WriteLn;
  298.        RETURN FALSE;
  299.       ELSE
  300.         maxcol := 0;
  301.         IF ( NOT getmaxcol(maxcol,argv^[J + 1]^) ) THEN
  302.           RETURN FALSE;
  303.         END;
  304.        J := J + 2;
  305.       END;
  306.     ELSE
  307.       Unused[UnusedArgs] := J;
  308.       UnusedArgs := UnusedArgs + 1;
  309.       J := J + 1;
  310.     END;
  311.   END;
  312.  
  313.   (* Pull out any remaining positional arguments from the command line: *)
  314.   J := 0;
  315.   IF ( ( CompareStringCAP(infile,"") = equal ) AND (J < UnusedArgs) ) THEN
  316.     CopyString(infile,argv^[Unused[J]]^);
  317.     J := J + 1;
  318.   END;
  319.   IF ( ( CompareStringCAP(outfile,"") = equal ) AND (J < UnusedArgs) ) THEN
  320.     CopyString(outfile,argv^[Unused[J]]^);
  321.     J := J + 1;
  322.   END;
  323.   IF ( width = 0 ) AND (J < UnusedArgs) THEN
  324.     IF ( NOT getwidth(width,argv^[Unused[J]]^) ) THEN
  325.       RETURN FALSE;
  326.     END;
  327.     J := J + 1;
  328.   END;
  329.   IF ( width = 0) THEN
  330.     width := DefaultWindowWidth;
  331.   END;
  332.   IF ( maxcol = 0 ) AND (J < UnusedArgs) THEN
  333.     IF ( NOT getmaxcol(maxcol,argv^[Unused[J]]^) ) THEN
  334.       RETURN FALSE;
  335.     END;
  336.     J := J + 1;
  337.   END;
  338.   IF ( maxcol = 0 ) THEN
  339.     maxcol := (width + 1) DIV 2;
  340.   END;
  341. (*
  342.   WriteLn;
  343. *)
  344.   RETURN TRUE;
  345. END getcmdline;
  346.  
  347. PROCEDURE writebitch;
  348. BEGIN
  349.   WriteString("column_set: Error -- problem writing OutFile = ");
  350.   WriteString(OutFile);
  351.   WriteLn;
  352.   IF (UsingStdInput) THEN
  353.     Close(TempFile);
  354.     Delete(TempFileName);
  355.   END;
  356.   IF (NOT UsingStdOutput) THEN
  357.     CloseOutput;
  358.   END;
  359.   RETURN;
  360. END writebitch;
  361.  
  362. BEGIN (* column_set *)
  363.  
  364. IF ( argc > 1 ) THEN
  365.   IF ( CompareStringCAP(argv^[1]^,"?") = equal ) THEN
  366.     usage;
  367.     RETURN;
  368.   END;
  369. END;
  370.  
  371. IF ( NOT getcmdline(InFile,OutFile,WindowWidth,MaxColumns) ) THEN
  372.   WriteString("column_set: Error -- unable to correctly parse command line!");
  373.   WriteLn;
  374.   usage;
  375.   RETURN;
  376. (*
  377. ELSE
  378.   WriteString("InFile      = "); WriteString(InFile); WriteLn;
  379.   WriteString("OutFile     = "); WriteString(OutFile); WriteLn;
  380.   WriteString("WindowWidth = "); WriteInt(WindowWidth,1); WriteLn;
  381.   WriteString("MaxColumns  = "); WriteInt(MaxColumns,1); WriteLn;
  382. *)
  383. END;
  384.  
  385. IF (CompareStringCAP(InFile,"") = equal) THEN
  386.   UsingStdInput := TRUE;
  387. ELSE
  388.   UsingStdInput := FALSE;
  389. END;
  390.  
  391. IF (CompareStringCAP(OutFile,"") = equal) THEN
  392.   UsingStdOutput := TRUE;
  393. ELSE
  394.   UsingStdOutput := FALSE;
  395. END;
  396.  
  397. IF ( UsingStdInput) THEN
  398.   Lookup(TempFile,TempFileName,TRUE);
  399.   IF (TempFile.res <> done) THEN
  400.     WriteString
  401.       ("column_set: Error -- unable to open new work file T:column_set.temp");
  402.     WriteLn;
  403.     RETURN;
  404.   END;
  405. (*
  406.   WriteString("column_set: taking data from standard input"); WriteLn;
  407. *)
  408. ELSE
  409.   OpenInputFile(InFile);
  410.   IF (NOT Done) THEN
  411.     WriteString("column_set: Error -- file open failed for InFile = ");
  412.     WriteString(InFile); WriteLn;
  413.     RETURN;
  414.   END;
  415. (*
  416.   WriteString("column_set: taking data from a named file"); WriteLn;
  417. *)
  418. END;
  419.  
  420. MaxLength := 0;
  421. ThisLength := 0;
  422. WentOK := TRUE;
  423.  
  424. IF ( UsingStdInput ) THEN
  425.   Terminal.Read(Ch);
  426.   IF (eof) THEN
  427.     WriteString
  428.       ("column_set: Error -- standard input looks empty in counting pass");
  429.     WentOK := FALSE;
  430.   END;
  431. ELSE
  432.   Read(Ch);
  433.   IF (NOT Done) THEN
  434.     WriteString("column_set: Error -- input file looks empty in counting pass")
  435.  
  436.     WentOK := FALSE;
  437.   END;
  438. END;
  439.  
  440. IF (NOT WentOK) THEN
  441.   WriteLn;
  442.   Close(TempFile);
  443.   Delete(TempFileName);
  444.   IF (NOT UsingStdInput) THEN
  445.     CloseInput;
  446.   END;
  447.   RETURN;
  448. END;
  449.  
  450. LOOP
  451.   IF ( UsingStdInput ) THEN
  452.     WriteChar(TempFile,Ch);
  453.     IF (TempFile.res = notdone) THEN
  454.       WriteString
  455.         ("column_set: Error -- problem writing to file T:column_set.temp");
  456.       WriteLn;
  457.       Close(TempFile);
  458.       Delete(TempFileName);
  459.       RETURN;
  460.     END;
  461.   END;
  462.   IF (Ch <> EOL) THEN
  463.     ThisLength := ThisLength + 1;
  464.   ELSE
  465.     IF (ThisLength > MaxLength) THEN
  466.       MaxLength := ThisLength;
  467.     END;
  468.     ThisLength := 0;
  469.   END;
  470.   IF (UsingStdInput) THEN
  471.     Terminal.Read(Ch);
  472.     IF (eof) THEN
  473.       EXIT;
  474.     END;
  475.   ELSE
  476.     Read(Ch);
  477.     IF (NOT Done) THEN
  478.       EXIT;
  479.     END;
  480.   END;
  481. END;
  482.  
  483. IF ( UsingStdInput ) THEN
  484.   Close(TempFile);
  485.   IF (TempFile.res = notdone) THEN
  486.     WriteString
  487.       ("column_set: Error -- unable to close file T:column_set.temp after");
  488.     WriteString(" counting pass"); WriteLn;
  489.     RETURN;
  490.   END;
  491.   Lookup(TempFile,TempFileName,FALSE);
  492.   IF (TempFile.res <> done) THEN
  493.     WriteString
  494.       ("column_set: Error -- unable to open file T:column_set.temp before");
  495.     WriteString(" writing pass"); WriteLn;
  496.     Delete(TempFileName);
  497.     RETURN;
  498.   END;
  499. ELSE
  500.   CloseInput;
  501.   OpenInputFile(InFile);
  502.   IF (NOT Done) THEN
  503.     WriteString("column_set: Error -- File reopen failed for InFile = ");
  504.     WriteString(InFile); WriteLn;
  505.     RETURN;
  506.   END;
  507. END;
  508.  
  509. IF (NOT UsingStdOutput) THEN
  510.   OpenOutputFile(OutFile);
  511.   IF (NOT Done) THEN
  512.     WriteString("column_set: Error -- file open failed for OutFile = ");
  513.     WriteString(OutFile); WriteLn;
  514.     Close(TempFile);
  515.     Delete(TempFileName);
  516.     RETURN;
  517.   END;
  518. END;
  519.  
  520. NumColumns := (WindowWidth + 1) DIV (MaxLength + 1);
  521. IF (NumColumns > MaxColumns) THEN
  522.   NumColumns := MaxColumns;
  523. END;
  524. IF (NumColumns > 1) THEN
  525.   NumSpaces := (WindowWidth - (NumColumns * MaxLength)) DIV (NumColumns - 1);
  526. ELSE
  527.   NumSpaces := 0;
  528. END;
  529.  
  530. ThisLength := 0;
  531. ThisColumn := 0;
  532. IF ( UsingStdInput ) THEN
  533.   ReadChar(TempFile,Ch);
  534.   IF (TempFile.res <> done) THEN
  535.     IF (TempFile.eof) THEN
  536.       WriteString
  537. ("column_set: Error -- Temporary Input File Looks Empty In Writing Pass");
  538.       WriteLn;
  539.     ELSE
  540.       WriteString
  541.         ("column_set: Error -- problem reading from T:column_set.temp");
  542.     END;
  543.     Close(TempFile);
  544.     Delete(TempFileName);
  545.     IF (NOT UsingStdOutput) THEN
  546.       CloseOutput;
  547.     END;
  548.     RETURN;
  549.   END;
  550. ELSE
  551.   Read(Ch);
  552.   IF (NOT Done) THEN
  553.     WriteString("column_set: Error -- Input File Looks Empty In Writing Pass");
  554.     WriteLn;
  555.     IF (NOT UsingStdOutput) THEN
  556.       CloseOutput;
  557.     END;
  558.     CloseInput;
  559.     RETURN;
  560.   END;
  561. END;
  562.  
  563. LOOP
  564.   IF (Ch <> EOL) THEN
  565.     ThisLength := ThisLength + 1;
  566.     IF ( UsingStdOutput ) THEN
  567.       Terminal.Write(Ch);
  568. (*
  569.       Module InOut "Done" documentation is buggy; omit checks after write;
  570.       Wirth didn't specify them, and BENCHMARK doesn't support them.
  571.       No way to check "Terminal" output result - not good when redirected
  572.       to a disk file that might overflow!
  573.  
  574.       WriteString("column_set: Error -- problem writing standard output");
  575. *)
  576.     ELSE
  577.       Write(Ch);
  578. (*
  579.     Module InOut "Done" documentation is buggy; omit checks after write;
  580.     Wirth didn't specify them, and BENCHMARK doesn't support them.
  581.       IF (NOT Done) THEN
  582.         writebitch;
  583.         RETURN;
  584.       END;
  585. *)
  586.     END;
  587.   ELSE
  588.     ThisColumn := ThisColumn + 1;
  589.     IF (ThisColumn < NumColumns) THEN
  590.       FOR I := ThisLength + 1 TO MaxLength + NumSpaces BY 1 DO
  591.         IF (UsingStdOutput) THEN
  592.           Terminal.Write(" ");
  593.         ELSE
  594.           Write(" ");
  595.           IF (NOT Done) THEN
  596.             writebitch;
  597.             RETURN;
  598.           END;
  599.         END;
  600.       END;
  601.     ELSE
  602.       IF (UsingStdOutput) THEN
  603.         Terminal.WriteLn;
  604.       ELSE
  605.         Write(EOL);
  606. (*
  607.     Module InOut "Done" documentation is buggy; omit checks after write;
  608.     Wirth didn't specify them, and BENCHMARK doesn't support them.
  609.  
  610.         IF (NOT Done) THEN
  611.           writebitch;
  612.           RETURN;
  613.         END;
  614. *)
  615.       END;
  616.       ThisColumn := 0;
  617.     END;
  618.     ThisLength := 0;
  619.   END;
  620.   IF ( UsingStdInput ) THEN
  621.     ReadChar(TempFile,Ch);
  622.     IF (TempFile.res <> done) THEN
  623.       IF (TempFile.eof) THEN
  624.         EXIT;
  625.       ELSE
  626.         WriteString
  627.           ("column_set: Error -- problem reading from T:column_set.temp");
  628.         Close(TempFile);
  629.         Delete(TempFileName);
  630.         IF (NOT UsingStdOutput) THEN
  631.           CloseOutput;
  632.         END;
  633.         RETURN;
  634.       END;
  635.     END;
  636.   ELSE
  637.     Read(Ch);
  638.     IF (NOT Done) THEN (* Unable to differentiate read error from eof *)
  639.       EXIT;
  640.     END;
  641.   END;
  642. END;
  643.  
  644. IF (ThisColumn <> 0) THEN
  645.   IF (UsingStdOutput) THEN
  646.     Terminal.WriteLn;
  647.   ELSE
  648.     Write(EOL);
  649. (*
  650.     Module InOut "Done" documentation is buggy; omit checks after write;
  651.     Wirth didn't specify them, and BENCHMARK doesn't support them.
  652.     IF (NOT Done) THEN
  653.       writebitch;
  654.       RETURN;
  655.     END;
  656. *)
  657.   END;
  658. END;
  659.  
  660. IF ( UsingStdInput ) THEN
  661.   Close(TempFile);
  662.   Delete(TempFileName);
  663. ELSE
  664.   CloseInput;
  665. END;
  666.  
  667. IF (NOT UsingStdOutput) THEN
  668.   CloseOutput;
  669. END;
  670.  
  671. END column_set.
  672.