home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ctformat.zip / CTF.S < prev    next >
Text File  |  1993-02-06  |  2KB  |  57 lines

  1. /*************************************************************/
  2. /*                                                           */
  3. /* CTF.S    Invokes CTFORMAT to format C/C++,                */
  4. /*          Assembler, and WYSIWYG Text Files                */
  5. /*                                                           */
  6. /*          Written by Scott T Jones                         */
  7. /*                                                           */
  8. /* Creates command ctf_format.  When called the current file */
  9. /* is saved as CTFORMAT.$$A, run thru the CTFORMAT filter to */
  10. /* produce CTFORMAT.$$B, and reloaded to replace the current */
  11. /* file.  These files are deleted at the end of the process. */
  12. /* ctf_format allows you to reformat your file, then save it */
  13. /* independent of the reformating.                           */
  14. /*                                                           */
  15. /* No keys are changed.  It is up to the user to bind this   */
  16. /* command to a SLICK key or call it from the command line.  */
  17. /*                                                           */
  18. /* To use this command, CTFORMAT.EXE is required in the      */
  19. /* execution path of your system.                            */
  20. /*                                                           */
  21. /*************************************************************/
  22.  
  23. defc ctf_format
  24.     ctf_buf_name=.buf_name
  25.     ctf_first_y=.cursor_y
  26.     ctf_line=.line
  27.     ctf_col=.col
  28.     .line=0
  29.     .line=ctf_line
  30.     ctf_second_y=.cursor_y
  31.     message 'Formatting with CTFORMAT'
  32.     write_file 'ctformat.$$a'
  33.     if rc<>0 then
  34.        message 'Error encountered while saving'
  35.        stop
  36.     endif
  37.     quiet_shell 'ctformat b <ctformat.$$a >ctformat.$$b'
  38.     if rc<>0 then
  39.        message 'Error encountered while formatting'
  40.        delete_file 'ctformat.$$a'
  41.        delete_file 'ctformat.$$b'
  42.        stop
  43.     endif
  44.     'edit ctformat.$$b'
  45.     'prev-buffer'
  46.     .modify=0
  47.     'quit'
  48.     'next-buffer'
  49.     name_file( ctf_buf_name )
  50.     .modify=1
  51.     .line=ctf_line + ctf_second_y - ctf_first_y
  52.     .line=ctf_line
  53.     .col=ctf_col
  54.     delete_file 'ctformat.$$a'
  55.     delete_file 'ctformat.$$b'
  56.     message 'Formatting complete'
  57.