home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip512.zip / vms / cvthelp.tpu < prev    next >
Text File  |  1994-07-06  |  4KB  |  169 lines

  1. !    TITLE    CVTHELP.TPU
  2. !    IDENT    01-000
  3. !
  4. !++
  5. !
  6. !  Program:    CVTHELP.TPU
  7. !
  8. !  Author:    Hunter Goatley
  9. !
  10. !  Date:    January 12, 1992
  11. !
  12. !  Purpose:    Convert .HELP files to RUNOFF .RNH files.  Substitutes
  13. !        RUNOFF commands for tags imbedded in the .HELP file.
  14. !
  15. !  Calling sequence:
  16. !
  17. !    $ EDIT/TPU/NOJOURNAL/NODISPLAY/COMMAND=CVTHELP file.HELP
  18. !
  19. !  Modified by:
  20. !
  21. !    01-000        Hunter Goatley         12-JAN-1992 15:15
  22. !        Original version.
  23. !
  24. !--
  25. Procedure eve_convert_help
  26. Local    temp
  27.     ,x
  28.     ;
  29.  
  30.    qualifier_level := 0;
  31.    hg$substitute_topic(current_buffer, "<MAIN>", ".indent-3", "1");
  32.    hg$substitute_topic(current_buffer, "<QUALIFIER>", ".sk;.indent-3", "");
  33.    hg$substitute_topic(current_buffer, "<TOPIC>", ".indent-3", "2");
  34.    hg$substitute_topic(current_buffer, "<SUBTOPIC>", ".indent-3", "3");
  35.    hg$substitute_topic(current_buffer, "<SUBSUBTOPIC>", ".indent-3", "4");
  36.    hg$substitute_comment(current_buffer,"<QUALIFIERS>",".indent-3;2 Qualifiers");
  37.    hg$substitute_comment(current_buffer,"<PARAMETER>",".indent-2");
  38.    hg$substitute_comment(current_buffer,"<PTEXT>",".lm+3");
  39.    hg$substitute_comment(current_buffer,"<TXETP>",".lm-3");
  40.    hg$substitute_comment(current_buffer,"<ETEXT>",".lm+4");
  41.    hg$substitute_comment(current_buffer,"<TXETE>",".lm-4");
  42.    hg$substitute_comment(current_buffer,"<INIT>",".noflags;.lm3;.rm70");
  43.    hg$substitute_comment(current_buffer,"<LITERAL>",".lm+4;.literal");
  44.    hg$substitute_comment(current_buffer,"<LARETIL>",".end literal;.lm-4");
  45.    hg$substitute_comment(current_buffer,"<DOT1LIST>",'.list 1,"o"');
  46.    hg$substitute_comment(current_buffer,"<DOT0LIST>",'.list 0,"o"');
  47.    hg$substitute_comment(current_buffer,"<ENTRY>",".le");
  48.    hg$substitute_comment(current_buffer,"<TSIL>",".end list");
  49.    hg$substitute_comment(current_buffer,"<CENTER>",".center");
  50.    hg$substitute_comment(current_buffer,"<FORMAT>",".sk;.indent2");
  51.    hg$substitute_comment(current_buffer,"<NOTE>",".note");
  52.    hg$substitute_comment(current_buffer,"<ETON>",".end note");
  53.    hg$substitute_comment(current_buffer, LINE_BEGIN & LINE_END,".sk");
  54.    hg$substitute_comment(current_buffer, LINE_BEGIN & "|", "");
  55.  
  56. EndProcedure;        ! eve_convert_help
  57.  
  58. Procedure hg$substitute_comment (the_buffer, target, new)
  59. Local    temp
  60.     ,save_pos
  61.     ,x
  62.     ;
  63.   on_error;
  64.   endon_error;
  65.  
  66.   save_pos := mark(none);
  67.   position(beginning_of(the_buffer));
  68.   loop
  69.     x := search(target, forward);
  70.     exitif x = 0;
  71.     position (x);
  72.     erase_character(length(x));
  73.     copy_text(new);
  74.   endloop;
  75.  
  76.   position(save_pos);
  77.  
  78. EndProcedure;        ! hg$substitute_comment
  79.  
  80. Procedure hg$substitute_topic (the_buffer, target, new, level)
  81. Local    temp
  82.     ,save_pos
  83.     ,x
  84.     ;
  85.   on_error;
  86.   endon_error;
  87.  
  88.   save_pos := mark(none);
  89.   position(beginning_of(the_buffer));
  90.   loop
  91.     x := search(target, forward);
  92.     exitif x = 0;
  93.     position (x);
  94.     erase_character(length(x));
  95.     move_vertical(-1);
  96.     if (length(current_line) = 0)
  97.     then copy_text("|");
  98.     endif;
  99.     move_vertical(1);
  100.     copy_text(".!------------------------------------------------------");
  101.     split_line;
  102.     copy_text(new);
  103.     move_horizontal(-current_offset);
  104.     move_vertical(1);
  105.     if level <> "" then
  106.         copy_text(level + " ");
  107. !    else
  108. !        if qualifier_level = 0
  109. !        then
  110. !            copy_text("2 Qualifiers");
  111. !        split_line; split_line;
  112. !        copy_text(new); split_line;
  113. !        qualifier_level := 1;
  114. !        endif;
  115.     endif;
  116.     move_horizontal(-current_offset);
  117.     move_vertical(1);
  118.     if length(current_line) = 0
  119.     then
  120.         if (target = "<MAIN>") OR (target = "<TOPIC>")
  121.         OR (target = "<SUBTOPIC>") or (target = "<SUBSUBTOPIC>")
  122.         then copy_text(".br");
  123.         else copy_text(".sk");
  124.         endif;
  125.     endif;
  126.   endloop;
  127.  
  128.   position(save_pos);
  129.  
  130. EndProcedure;        ! hg$substitute_topic
  131.  
  132. !===============================================================================
  133. Procedure tpu$init_procedure
  134. Local    temp
  135.     ,orig_filespec
  136.     ,f
  137.     ;
  138.  
  139.    on_error
  140.    endon_error;
  141.  
  142.  !Prompt user for information
  143.  
  144.   orig_filespec := get_info(command_line, "file_name");
  145.   if orig_filespec = ""
  146.   then
  147.     message("No .HELP file given");
  148.     quit;
  149.   endif;
  150.   f := file_parse(orig_filespec, ".HELP");        !Add .LIS ending
  151.  
  152.     ! Create a buffer and window for editing
  153.  
  154.   main_buf := create_buffer ("MAIN",f);
  155.   set (eob_text, main_buf, "[End of buffer]");
  156.  
  157.   position (beginning_of(main_buf));
  158.  
  159.   eve_convert_help;
  160.  
  161.   f := file_parse(orig_filespec,"","",NAME);
  162.  
  163.   write_file (main_buf, f+".RNH");
  164.  
  165.  quit;
  166. EndProcedure;        !TPU$INIT_PROCEDURE
  167.  
  168. tpu$init_procedure;
  169.