home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / internet / yamtools20 / yamtools20english / ytreformat.rexx < prev    next >
OS/2 REXX Batch file  |  1997-08-08  |  54KB  |  1,512 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /*                            YTReFormat                                      */
  4. /*                 Copyright ©1997 by Dick Whiting                            */
  5. /*                                                                            */
  6. /*----------------------------------------------------------------------------*/
  7. /*    This version requires MuiRexx 3.0 use Yamtools 1.7 with MuiRexx 2.2     */
  8. /*----------------------------------------------------------------------------*/
  9. /* This script requires YAMTOOLS for it to work. If you don't have YAMTOOLS   */
  10. /* you can get it on Aminet in directory comm/mail. This script allows you    */
  11. /* to rewrap a mail file. I FINALLY got tired of doing it the hard way.       */
  12. /* I would have liked to make it automatic, but just couldn't see how.        */
  13. /* The current version will make all the quoting the same or remove it.       */
  14. /* If you have any ideas for additional reformatting, contact me.             */
  15. /*----------------------------------------------------------------------------*/
  16. /* To use this select a mail and adjust the outer and inner quoting when      */
  17. /* prompted. The outer quoting should be the character(s) or possibly none    */
  18. /* that prefix the piece of lines that got wrapped badly. The inner quoting   */
  19. /* should be the remainder (or none) necessary to make the lines uniform.     */
  20. /* Sorry, if that is unclear. Play with it using the UNDO/REDO to figure      */
  21. /* out how to make it work.                                                   */
  22. /*----------------------------------------------------------------------------*/
  23. /*                                                                            */
  24. /* Standard Disclaimer: I wrote it, it works for me, I don't guarantee        */
  25. /* that it will do anything productive for anyone else, etc. etc. ;-)         */
  26. /*                                                                            */
  27. /*HOWEVER, if you DO find a use for it: I homeschool my kids and they         */
  28. /*would love a postcard from where EVER you live.                             */
  29. /*                                                                            */
  30. /*Instant GEOGRAPHY lesson;)                                                  */
  31. /*                                                                            */
  32. /*                                                                            */
  33. /*POSTCARDS:    Dick Whiting                                                  */
  34. /*              28590 S. Beavercreek Rd.                                      */
  35. /*              Mulino, Oregon 97042                                          */
  36. /*              USA                                                           */
  37. /*                                                                            */
  38. /*----------------------------------------------------------------------------*/
  39. /*                                                                            */
  40. /*               Address Bug Reports or Comments to:                          */
  41. /*                Dick Whiting <dwhiting@europa.com>                          */
  42. /*                           15 June 1997                                     */
  43. /*                                                                            */
  44. /******************************************************************************/
  45. /*
  46. $VER: 2.0 Copyright ©1997 by Dick Whiting
  47. $AUTHOR: Dick Whiting
  48. $DESCRIPTION: Re-Format a mail file - needs YAMTOOLS
  49. */
  50.  
  51. options results
  52. options failat 21
  53.  
  54. wrapparm=''
  55. parse arg mainparm subparm
  56.  
  57. /**************************************************************************/
  58. /*                         Initialize Variables                           */
  59. /**************************************************************************/
  60. Call MUIvars                                /* go define vars for MUI use */
  61. Call YTvars                                 /* various values used in YT  */
  62. Call Helpvars                               /* pointers into HELP guide   */
  63. Call Localize                               /* vars for localizing strings*/
  64. Call Builtvars                              /* built using previous values*/
  65.  
  66. Address YAMTOOLS
  67.  
  68. Call CheckYam
  69.  
  70. Select
  71.    when mainparm='' then do
  72.       Call CheckDup
  73.       Call GetYamInfo
  74.       Call ReadMail
  75.    end
  76.    when mainparm='DONE' then do
  77.       Call SaveFile   
  78.       Call Quit
  79.    end
  80.    when mainparm='SAVE' then do
  81.       Call SaveFile   
  82.    end
  83.    when mainparm='REWRAP' | mainparm='UNQUOTE' then do
  84.       Call AskUser
  85.    end
  86.    when mainparm='DOREWRAP' | mainparm='DOUNQUOTE' then do
  87.       Call ValidateUser
  88.       Call WrapBlock
  89.    end
  90.    when mainparm='STYLE' then do
  91.       Call Stylelines
  92.    end
  93.    when mainparm='STYLEIT' then do
  94.       Call StyleIt
  95.    end
  96.    when mainparm='NEWHEAD' then do
  97.       Call NewHead 
  98.    end
  99.    when mainparm='HEADIT' then do
  100.       Call HeadIt
  101.    end
  102.    when mainparm='UNMIME' then do
  103.       Call GetYamInfo
  104.       method ID YTRFH MUIM_List_Clear
  105.       method ID YTRFT MUIM_List_Clear
  106.       method ID YTRFM MUIM_List_Clear
  107.       Call UnMime
  108.       Call ReadMail
  109.    end
  110.    when mainparm='UNDO' then do
  111.       Call Undo
  112.    end
  113.    when mainparm='REDO' then do
  114.       Call Redo
  115.    end
  116.    when mainparm='QUIT' then do
  117.       Call Quit
  118.    end
  119.    otherwise do
  120.       errmsg=_text._badparm
  121.       Call ErrorMsg
  122.    end
  123. end 
  124.  
  125. exit
  126.  
  127. /**************************************************************************/
  128. /*                        Read the mail file into array                   */
  129. /**************************************************************************/
  130. ReadMail:     
  131.  
  132.     header.=' '
  133.  
  134.    i=0
  135.    header=TRUE
  136.    quoted=FALSE
  137.  
  138.    if open('IN',mfile,'R') then do
  139.       Call BuildWindow
  140.       infotext=_text._procmail
  141.       infobuttons=''
  142.       showbusy=TRUE
  143.       Call InfoWindow
  144.  
  145.       list ID YTRFT ATTRS MUIA_List_Quiet TRUE 
  146.       list ID YTRFM ATTRS MUIA_List_Quiet TRUE 
  147.       do until eof('IN')
  148.          linein=readln('IN')
  149.          linein=translate(linein,' ',tab) 
  150.          if header then do
  151.             list ID YTRFH INSERT POS MUIV_List_Insert_Bottom STRING '='linein
  152.             if linein='' then do 
  153.                     header=FALSE
  154.                     do j=1 to 4
  155.                    list ID YTRFT INSERT POS MUIV_List_Insert_Bottom,
  156.                               STRING '='header.j
  157.                     end
  158.                 end
  159.                 select
  160.                 when upper(word(linein,1))='FROM:' then header.1=linein
  161.                 when upper(word(linein,1))='TO:'   then header.2=linein
  162.                 when upper(word(linein,1))='DATE:' then header.3=linein
  163.                 when upper(word(linein,1))='SUBJECT:' then header.4=linein
  164.                 when upper(word(linein,1))='CONTENT-TRANSFER-ENCODING:' then do
  165.                   encoding=word(linein,2)
  166.                   if upper(encoding)='QUOTED-PRINTABLE' then quoted=TRUE
  167.                end
  168.                     otherwise nop
  169.                 end
  170.          end
  171.          else do
  172.             if ~eof('IN') then do
  173.                linein=right(i,5,'0')||',='||linein
  174.                list ID YTRFM INSERT POS MUIV_List_Insert_Bottom, 
  175.                     ATTRS MUIA_List_Format '"WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,"',
  176.                     STRING linein
  177.                i=i+1
  178.             end
  179.          end
  180.       end
  181.       foo=close('IN')
  182.       list ID YTRFT ATTRS MUIA_List_Quiet FALSE
  183.       list ID YTRFM ATTRS MUIA_List_Quiet FALSE
  184.       window ID YTINF close
  185.    end
  186.    else do
  187.       errmsg=_text._badmail
  188.       Call ErrorMsg
  189.       exit     
  190.    end
  191.    
  192.    if quoted then do
  193.       errmsg=_text._prtquoted
  194.       Call ErrorMsg
  195.       exit
  196.    end
  197.    
  198. Return
  199.  
  200. /**************************************************************************/
  201. /*                        Save the mail file back                         */
  202. /**************************************************************************/
  203. SaveFile:     
  204.  
  205.    infotext=_text._savemail    
  206.    infobuttons=''
  207.    showbusy=TRUE
  208.    Call InfoWindow
  209.  
  210.    text ID YTRFF
  211.    mfile=result
  212.  
  213.    fstate=statef(mfile)                           /* file information     */
  214.    fbytes=subword(fstate,2,1)                     /* length of file       */
  215.    fdate=subword(fstate,5,1)                      /* internal date        */
  216.    fmins=subword(fstate,6,1)                      /* minutes since midnite*/
  217.    fticks=subword(fstate,7,1)                     /* ticks past minutes   */
  218.    fcomm=subword(fstate,8)                        /* old comment          */
  219.  
  220.    fdate=date('E',fdate,'I')                      /* get date in ddmmyy   */
  221.    fdate=translate(fdate,'-','/')                 /* convert / to -       */
  222.    hh=fmins%60                                    /* get hours            */
  223.    hh=right(hh,2,'0')                             /* force to 2 digits    */
  224.    mm=fmins//60                                   /* get minutes          */
  225.    mm=right(mm,2,'0')                             /* force to 2 digits    */
  226.    ss=fticks%50                                   /* seconds              */
  227.    ss=right(ss,2,'0')                             /* force it             */
  228.    ftime=hh||':'||mm||':'||ss                     /* timestamp rebuilt    */
  229.  
  230.    if open('OUT',mfile,'W') then do
  231.       list ID YTRFH ATTRS MUIA_List_Entries       /* process header recs  */
  232.       mcnt=result
  233.       do i=0 to mcnt-1   
  234.          list ID YTRFH POS i
  235.          lineout=result
  236.          foo=writeln('OUT',lineout)
  237.       end
  238.       list ID YTRFM ATTRS MUIA_List_Entries
  239.       mcnt=result
  240.       do i=0 to mcnt-1   
  241.          list ID YTRFM POS i
  242.          lineout=result
  243.          lineout=substr(lineout,7)                /* strip number         */
  244.          foo=writeln('OUT',lineout)
  245.       end
  246.       foo=close('OUT')
  247.    end
  248.  
  249.    Address Command 'SetDate ' mfile fdate ftime
  250.  
  251.    window ID YTINF close
  252.    
  253. Return
  254.  
  255. /**************************************************************************/
  256. /*                        Validate User Input                             */
  257. /**************************************************************************/
  258. ValidateUser:
  259.  
  260.    string ID RUSR1 
  261.    OutQuote=result
  262.  
  263.    string ID RUSR2
  264.    InnQuote=result
  265.  
  266.    string ID RUSR3
  267.    WordWrap=result
  268.  
  269.    if ~datatype(WordWrap,'W') then do
  270.       errmsg=_text._wwnotnum
  271.       Call ErrorMsg
  272.       exit     
  273.    end
  274.  
  275.    wraplen=wordwrap-(length(OutQuote)+length(InnQuote))
  276.  
  277.    if WordWrap<wrapmin1 | WordWrap>wrapmax then do
  278.       errmsg=_text._wwoutrange
  279.       Call ErrorMsg
  280.       exit     
  281.    end
  282.  
  283.    if wraplen<wrapmin2 then do
  284.       errmsg=_text._wwshort
  285.       Call ErrorMsg
  286.       exit     
  287.    end
  288.  
  289.    window ID YTUSR close
  290.    
  291. Return
  292.  
  293. /**************************************************************************/
  294. /*                        Do the actual wrapping                          */
  295. /**************************************************************************/
  296. WrapBlock:
  297.  
  298.    WWarray.=missing
  299.    j=0
  300.  
  301.    startpos=0                            /* top of list for default       */
  302.  
  303.    list ID YTRFM ATTRS MUIA_List_Entries
  304.    mcnt=result
  305.  
  306.    do i=0 to mcnt-1                      /* locate selected lines to wrap */
  307.       list ID YTRFM 
  308.       wstring=result
  309.       if wstring='' then leave i
  310.       j=substr(wstring,1,5)+0
  311.       if startpos=0 then startpos=j      /* first line rewrapped          */
  312.       WWarray.j=substr(wstring,7)        /* strip prefix stuff            */
  313.    end
  314.  
  315.    if i=0 then do                        /* user didn't select any        */
  316.       errmsg=_text._nolines          
  317.       Call ErrorMsg
  318.       exit     
  319.    end
  320.  
  321.    if mainparm='DOREWRAP' then infotext=_text._dowrap
  322.    else infotext=_text._dounquote
  323.    infobuttons=''
  324.    showbusy=TRUE
  325.    Call InfoWindow
  326.  
  327.    foo=open('OLD','T:YTReForm.old','W')  /* files for undo/redo functions */
  328.    foo=open('NEW','T:YTReForm.new','W')
  329.  
  330.    do i=0 to mcnt-1                      /* loop completely thru list     */
  331.       list ID YTRFM POS i
  332.       linein=result
  333.       if WWarray.i=missing then do       /* not a rewrap line             */
  334.          oldnum=left(linein,5)           /* the number portion            */
  335.          oldval=substr(linein,7)         /* the mail line                 */
  336.          lineout=oldnum||',='||oldval    /* rebuild with the equal sign   */
  337.          foo=writeln('OLD',lineout)      /* save line to OLD file         */
  338.          WWarray.i=substr(linein,7)      /* copy to new array             */
  339.       end
  340.       else do                            /* start of a block to rewrap    */
  341.          tempstr=''                      /* init to null rewrap string    */
  342.          do j=i to mcnt-1                /* loop thru the new array       */
  343.             linein=WWarray.j             /* get highlighted string ?      */
  344.             if linein=missing then leave j  /* block is complete          */
  345.             WWarray.j=missing            /* clear the entry for now       */
  346.             if OutQuote~='' then do
  347.                if substr(linein,1,length(OutQuote))=OutQuote then do
  348.                   linein=substr(linein,1+length(OutQuote))
  349.                end
  350.             end
  351.             if InnQuote~='' then do
  352.                if substr(linein,1,length(InnQuote))=InnQuote then do
  353.                   linein=substr(linein,1+length(InnQuote))
  354.                end
  355.             end
  356.             tempstr=tempstr||' '||linein /* unquoted text to rewrap       */
  357.             list ID YTRFM POS j          /* keep copying to OLD           */
  358.             linein=result
  359.             oldnum=left(linein,5)        /* the number portion            */
  360.             oldval=substr(linein,7)      /* the mail line                 */
  361.             lineout=oldnum||',='||oldval /* rebuild with the equal sign   */
  362.             foo=writeln('OLD',lineout)   /* save line to OLD file         */
  363.          end         
  364.          tempstr=substr(tempstr,2)       /* trim extra blank from start   */
  365.          outlines=0                      /* none processed yet            */
  366.  
  367.          do while length(tempstr)>0      /* the actual rewrapping!!!      */
  368.             blankpos=pos(' ',tempstr)    /* FIRST blank in remaining      */
  369.             select
  370.                when length(tempstr)<wraplen then do
  371.                  newstr=tempstr
  372.                  tempstr=''
  373.                end
  374.                when blankpos=0 then do
  375.                  newstr=tempstr
  376.                  tempstr=''
  377.                end
  378.                when blankpos>wraplen then do
  379.                   newstr=substr(tempstr,1,blankpos)
  380.                   tempstr=substr(tempstr,blankpos+1)
  381.                end
  382.                otherwise do
  383.                   newstr=substr(tempstr,1,lastpos(' ',substr(tempstr,1,wraplen)))
  384.                   tempstr=substr(tempstr,1+lastpos(' ',substr(tempstr,1,wraplen)))
  385.                end
  386.             end
  387.             if mainparm='DOREWRAP' then do  /* if rewrapping add prefix   */
  388.                newstr=OutQuote||InnQuote||newstr
  389.             end
  390.             k=i+outlines                 /* new pointer for array         */
  391.             WWarray.k=newstr             /* store the wrapped line        */
  392.             outlines=outlines+1
  393.          end
  394.          i=j-1                           /* decrement for loop control    */
  395.       end
  396.    end
  397.  
  398.  
  399. /**************************************************************************/
  400. /*  Clear the list, reload with rewrapped lines, copy to NEW file.        */
  401. /**************************************************************************/
  402.  
  403.    list ID YTRFM ATTRS MUIA_List_Entries
  404.    mcnt=result
  405.  
  406.    list ID YTRFM ATTRS MUIA_List_Visible
  407.    lastpos=result
  408.  
  409.    jumppos=lastpos+startpos-3
  410.    if jumppos>mcnt-1 then jumppos=mcnt-1
  411.  
  412.    list ID YTRFM ATTRS MUIA_List_Quiet TRUE 
  413.  
  414.    method ID YTRFM MUIM_List_Clear
  415.  
  416.    j=0
  417.    do i=0 to mcnt-1
  418.       if wwarray.i=missing then iterate  /* a null entry - skip it        */
  419.       lineout=right(j,5,'0')||',='||wwarray.i
  420.       foo=writeln('NEW',lineout)         /* write to the redo file        */
  421.       list ID YTRFM INSERT POS MUIV_List_Insert_Bottom STRING lineout
  422.       j=j+1                              /* pointer for list              */
  423.    end
  424.  
  425.    button ID YTRFU ATTRS MUIA_Disabled FALSE   /* unghost UNDO button     */
  426.    button ID YTRFR ATTRS MUIA_Disabled TRUE    /* ghost REDO button       */
  427.    
  428.    list ID YTRFM ATTRS MUIA_List_Quiet FALSE
  429.  
  430.    method ID YTRFM MUIM_List_Jump jumppos      /* go to first rewrapped   */
  431.  
  432.    foo=close('OLD')                      /* close undo file               */
  433.    foo=close('NEW')                      /* close redo file               */
  434.  
  435.    window ID YTINF close
  436.  
  437. Return
  438.  
  439. /**************************************************************************/
  440. /*  Prompt for new header line.                                           */
  441. /**************************************************************************/
  442. NewHead:    
  443.  
  444.    oldhead=translate(subparm,' ',tab) 
  445.    headtype=' '||word(oldhead,1)
  446.    oldhead=subword(oldhead,2)
  447.    newhead=oldhead
  448.  
  449.    result=''
  450.    text ID YTHD0
  451.    if result='' then do
  452.       Call HeadWin
  453.    end
  454.    else do
  455.       text ID YTHD0 LABEL headtype
  456.       string ID YTHD1 CONTENT oldhead
  457.       string ID YTHD2 CONTENT newhead
  458.    end
  459. Return
  460.  
  461. /**************************************************************************/
  462. /*  Process header changes.                                               */
  463. /**************************************************************************/
  464. HeadIt:
  465.  
  466.    if subparm='S' then do
  467.       text ID YTHD0
  468.       headtype=strip(result,'B')
  469.       string ID YTHD2
  470.       newhead=result
  471.       list ID YTRFH ATTRS MUIA_List_Entries
  472.       mcnt=result
  473.       do i=0 to mcnt-1   
  474.          list ID YTRFH POS i
  475.          oldhead=result
  476.          if substr(oldhead,1,length(headtype))=headtype then do
  477.             newhead=headtype||' '||newhead
  478.             list ID YTRFH POS i STRING newhead 
  479.             list ID YTRFT ATTRS MUIA_List_Entries
  480.             hcnt=result
  481.             do j=0 to hcnt-1   
  482.                list ID YTRFT POS j
  483.                oldhead=result
  484.                if substr(oldhead,1,length(headtype))=headtype then do
  485.                   list ID YTRFT POS j STRING newhead 
  486.                   leave j
  487.                end
  488.             end
  489.             leave i
  490.          end
  491.       end
  492.    end
  493.  
  494.    window ID YTHED close
  495.    
  496.  
  497. Return
  498. /**************************************************************************/
  499. /*  Get first line and open window                                        */
  500. /**************************************************************************/
  501. StyleLines:
  502.  
  503.    wstring=''
  504.    list ID YTRFM
  505.    wstring=result
  506.    if wstring='' then do
  507.       errmsg=_text._noslines
  508.       Call ErrorMsg
  509.       exit
  510.    end
  511.    sline=substr(wstring,7)
  512.    result=0
  513.    list ID YTSTM ATTRS MUIA_List_Entries
  514.    scnt=result
  515.    if scnt=0 then do
  516.       Call StyleWin
  517.    end
  518.    else do
  519.       method ID YTSTM MUIM_List_Clear
  520.    end
  521.    string ID YTSTT CONTENT insert('=',wstring,6)
  522.    string ID YTST1 CONTENT sline
  523.    do i=1 to words(sline)
  524.       slinex=right(i,2,'0')||',='||word(sline,i)
  525.       list ID YTSTM INSERT POS MUIV_List_Insert_Bottom,
  526.            ATTRS MUIA_List_Format '"WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,"',  
  527.            STRING slinex
  528.    end
  529.    maillist=sline
  530.    Call AnsiStyle
  531.    text ID YTST2 LABEL translate(maillist,' ',',')  
  532.  
  533. Return
  534.  
  535. /**************************************************************************/
  536. /*  Perform commands from styling window                                  */
  537. /**************************************************************************/
  538. StyleIt:
  539.  
  540.    select
  541.       when subparm='Q' then do
  542.          list ID YTRFM POS 0
  543.          list ID YTRFM
  544.          window ID YTSTY close
  545.       end
  546.       when subparm='S' then do
  547.          string ID YTSTT
  548.          wstring=result
  549.          wnum=substr(wstring,1,5)
  550.          list ID YTRFM POS wnum STRING wstring
  551.          list ID YTRFM
  552.          wstring=result
  553.          if wstring~='' then do
  554.             method ID YTSTM MUIM_List_Clear
  555.             sline=substr(wstring,7)
  556.             string ID YTST1 CONTENT sline
  557.             wstring=insert('=',wstring,6)
  558.             string ID YTSTT CONTENT wstring
  559.             do i=1 to words(sline)
  560.                slinex=right(i,2,'0')||',='||word(sline,i)
  561.                list ID YTSTM INSERT POS MUIV_List_Insert_Bottom,
  562.                     ATTRS MUIA_List_Format '"WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,"',
  563.                     STRING slinex
  564.             end
  565.             maillist=sline
  566.             Call AnsiStyle
  567.             text ID YTST2 LABEL translate(maillist,' ',',') 
  568.          end
  569.       end
  570.       when subparm='N' then do
  571.          list ID YTRFM
  572.          wstring=result
  573.          if wstring~='' then do
  574.             method ID YTSTM MUIM_List_Clear
  575.             sline=substr(wstring,7)
  576.             string ID YTST1 CONTENT sline
  577.             wstring=insert('=',wstring,6)
  578.             string ID YTSTT CONTENT wstring
  579.             do i=1 to words(sline)
  580.                slinex=right(i,2,'0')||',='||word(sline,i)
  581.                list ID YTSTM INSERT POS MUIV_List_Insert_Bottom,
  582.                     ATTRS MUIA_List_Format '"WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,"',
  583.                     STRING slinex
  584.             end
  585.             maillist=sline
  586.             Call AnsiStyle
  587.             text ID YTST2 LABEL translate(maillist,' ',',') 
  588.          end
  589.       end
  590.       when subparm='E' then do
  591.          string ID YTSTT
  592.          wstring=result
  593.          wnum=substr(wstring,1,5)
  594.          string ID YTST1
  595.          wstring=result
  596.          if wstring~='' then do
  597.             method ID YTSTM MUIM_List_Clear
  598.             string ID YTSTT CONTENT wnum||',='||wstring
  599.             do i=1 to words(wstring)
  600.                slinex=right(i,2,'0')||',='||word(wstring,i)
  601.                list ID YTSTM INSERT POS MUIV_List_Insert_Bottom,
  602.                     ATTRS MUIA_List_Format '"WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,"',
  603.                     STRING slinex
  604.             end
  605.             maillist=wstring
  606.             Call AnsiStyle
  607.             text ID YTST2 LABEL translate(maillist,' ',',') 
  608.          end
  609.       end
  610.       otherwise do
  611.          list ID YTSTM ATTRS MUIA_List_Entries
  612.          scnt=result
  613.          do i=0 to scnt-1
  614.             list ID YTSTM
  615.             slinex=result
  616.             if slinex='' then leave i
  617.             snum=substr(slinex,1,2)+0
  618.             string ID YTSTT
  619.             wstring=result
  620.             wnum=substr(wstring,1,5)
  621.             slinex=substr(wstring,8)
  622.             swordx=word(slinex,snum)
  623.             spos=wordindex(slinex,snum)
  624.             slinex=delstr(slinex,spos,length(swordx))
  625.             select
  626.                when subparm='B' then do 
  627.                   swordx='*'||swordx||'*'      
  628.                   stylechar='*'
  629.                end
  630.                when subparm='C' then do 
  631.                   swordx='#'||swordx||'#'
  632.                   stylechar='#'
  633.                end
  634.                when subparm='I' then do 
  635.                   swordx='/'||swordx||'/'
  636.                   stylechar='/'
  637.                end
  638.                when subparm='U' then do 
  639.                   swordx='_'||swordx||'_'
  640.                   stylechar='_'
  641.                end
  642.                otherwise do 
  643.                   swordx=strip(swordx,'B','*')
  644.                   swordx=strip(swordx,'B','#')
  645.                   swordx=strip(swordx,'B','/')
  646.                   swordx=strip(swordx,'B','_')
  647.                   stylechar=''
  648.                end
  649.             end
  650.             wstring=insert(swordx,slinex,spos-1)
  651.             if snum>1 & stylechar~='' then do
  652.                if substr(wstring,spos-2,1)=stylechar then do
  653.                   wstring=delstr(wstring,spos,1)
  654.                   wstring=delstr(wstring,spos-2,1)
  655.                end
  656.             end
  657.             string ID YTSTT CONTENT wnum||',='||wstring
  658.             string ID YTST1 CONTENT wstring
  659.          end
  660.          if i>0 then do
  661.             method ID YTSTM MUIM_List_Clear
  662.             do i=1 to words(wstring)
  663.                slinex=right(i,2,'0')||',='||word(wstring,i)
  664.                list ID YTSTM INSERT POS MUIV_List_Insert_Bottom,
  665.                     ATTRS MUIA_List_Format '"WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,"',
  666.                     STRING slinex
  667.             end
  668.             maillist=wstring
  669.             Call AnsiStyle
  670.             text ID YTST2 LABEL translate(maillist,' ',',') 
  671.          end
  672.          else do
  673.             errmsg=_text._noslines
  674.             Call ErrorMsg
  675.             exit
  676.          end
  677.       end
  678.    end
  679. Return
  680.  
  681. /**************************************************************************/
  682. /*                        Convert styling to ANSI                         */
  683. /*                                                                        */
  684. /* Logic: Locate FIRST style character that fits rules.                   */
  685. /*        Locate FIRST same  character after it.                          */
  686. /*        If valid then replace those with ANSI codes.                    */
  687. /*           Save that portion and loop for possible others.              */
  688. /*        If NOT valid then loop looking for a new FIRST possibility.     */
  689. /*                                                                        */
  690. /* This appears to match the logic in Yam1.3.4 which probably will change */
  691. /* in Yam2.x Right now it seems that the next matching style character    */
  692. /* MUST be a valid ending one OR the starting one is invalid as a start.  */
  693. /*                                                                        */
  694. /**************************************************************************/
  695. AnsiStyle:     
  696.  
  697.    qline=TRUE
  698.    testword=word(maillist,1)
  699.    if pos('>',testword)=0 then do 
  700.       qline=FALSE
  701.       qattr=qoff
  702.    end
  703.  
  704.    mailtest=maillist
  705.    mailcopy=''
  706.  
  707.    spos=verify(mailtest,stylelist,'MATCH')
  708.  
  709.    do while spos>0
  710.       schar=substr(mailtest,spos,1)
  711.  
  712.       /* test if character BEFORE style character is a valid one */ 
  713.       if spos>1 then do        
  714.          tchar1=substr(mailtest,spos-1,1)
  715.          if verify(goodpre1,tchar1,'MATCH')=0 & tchar1~=goodpre2 then do
  716.             Call TrimIt
  717.             iterate         
  718.          end
  719.       end
  720.  
  721.       /* Character BEFORE style character IS valid - test one after it */
  722.       if spos<length(mailtest) then do
  723.          tchar2=substr(mailtest,spos+1,1)
  724.          if verify(badpost1,tchar2,'MATCH')>0 then do
  725.             Call TrimIt
  726.             iterate         
  727.          end
  728.       end
  729.       else do   /* all done - style char was last char in string */
  730.          mailcopy=mailcopy||mailtest
  731.          spos=0
  732.       end
  733.  
  734.       /* NOW locate the NEXT matching character if one                 */
  735.       epos=pos(schar,substr(mailtest,spos+1))
  736.  
  737.       /* if epos is not last character then check if following char val*/
  738.       if epos>0 then do
  739.           epos=spos+epos                         /* real position      */
  740.           if epos<length(mailtest) then do
  741.             tchar3=substr(mailtest,epos+1,1)  
  742.             if verify(goodpost1,tchar3,'MATCH')=0 then do
  743.                Call TrimIt
  744.                iterate         
  745.             end
  746.          end
  747.       end
  748.       else do  /* no matching end character */
  749.          Call TrimIt 
  750.          iterate         
  751.       end
  752.  
  753.       /* OK, have a valid START and END styling character                 */ 
  754.       if spos>1 then do 
  755.          temp1=substr(mailtest,1,spos-1)
  756.       end
  757.       else do 
  758.          temp1='' 
  759.       end
  760.  
  761.       temp2=substr(mailtest,spos+1,epos-spos-1)
  762.  
  763.       if epos<length(mailtest) then do 
  764.          temp3=substr(mailtest,epos+1)
  765.       end
  766.       else temp3=''  
  767.       
  768.       select
  769.          when schar='*' then temp2=SansiBold||temp2||EansiBold
  770.          when schar='#' then do 
  771.             if qline & mainparm='PRINT' then do 
  772.                temp2=EansiColr||temp2||EansiColr
  773.             end
  774.             else do
  775.                temp2=SansiColr||temp2||EansiColr
  776.             end 
  777.          end
  778.          when schar='_' then temp2=SansiUlin||temp2||EansiUlin
  779.          when schar='/' then temp2=SansiItal||temp2||EansiItal
  780.          otherwise nop
  781.       end
  782.       mailcopy=mailcopy||temp1||temp2
  783.       mailtest=qattr||temp3
  784.       spos=verify(mailtest,stylelist,'MATCH')
  785.    end 
  786.  
  787.    maillist=qattr||mailcopy||mailtest
  788.  
  789. Return
  790.  
  791. /**************************************************************************/
  792. /*                        Save the mail file back                         */
  793. /**************************************************************************/
  794. TrimIt:
  795.  
  796.    mailcopy=mailcopy||substr(mailtest,1,spos)
  797.    mailtest=substr(mailtest,spos+1)
  798.    if length(mailtest)>0 then do
  799.       spos=verify(mailtest,stylelist,'MATCH')
  800.    end
  801.    else do
  802.       spos=0
  803.    end
  804.  
  805. Return
  806.  
  807. /**************************************************************************/
  808. /*  Clear the list, reload from the OLD file, set button ghosting.        */
  809. /**************************************************************************/
  810. UNDO:
  811.  
  812.    button ID YTRFU ATTRS MUIA_Disabled TRUE    /* ghost UNDO button       */
  813.  
  814.    if open('IN','T:YTReForm.old','R') then do
  815.       infotext=_text._doredo
  816.       infobuttons=''
  817.       showbusy=TRUE
  818.       Call InfoWindow
  819.  
  820.       list ID YTRFM ATTRS MUIA_List_Entries
  821.       mcnt=result
  822.       list ID YTRFM ATTRS MUIA_List_Quiet TRUE
  823.  
  824.       method ID YTRFM MUIM_List_Clear
  825.  
  826.       do until eof('IN')
  827.          linein=readln('IN')
  828.          if ~eof('IN') then do
  829.             list ID YTRFM INSERT POS MUIV_List_Insert_Bottom STRING linein
  830.          end
  831.       end
  832.       foo=close('IN')
  833.       button ID YTRFR ATTRS MUIA_Disabled FALSE   /* unghost REDO button  */
  834.       list ID YTRFM ATTRS MUIA_List_Quiet FALSE
  835.       foo=close('OLD')                   /* close undo file               */
  836.       window ID YTINF close
  837.    end
  838.    else do
  839.       errmsg=_text._noundofile
  840.       Call ErrorMsg
  841.       exit
  842.    end
  843.  
  844.  
  845. Return
  846.  
  847. /**************************************************************************/
  848. /*  Clear the list, reload from the NEW file, set button ghosting.        */
  849. /**************************************************************************/
  850. REDO:
  851.  
  852.    button ID YTRFR ATTRS MUIA_Disabled TRUE    /* ghost REDO button       */
  853.  
  854.    if open('IN','T:YTReForm.new','R') then do
  855.       infotext=_text._doredo
  856.       infobuttons=''
  857.       showbusy=TRUE
  858.       Call InfoWindow
  859.  
  860.       list ID YTRFM ATTRS MUIA_List_Entries
  861.       mcnt=result
  862.       list ID YTRFM ATTRS MUIA_List_Quiet TRUE
  863.  
  864.       method ID YTRFM MUIM_List_Clear
  865.  
  866.       list ID YTRFM ATTRS MUIA_List_Quiet FALSE
  867.       list ID YTRFM ATTRS MUIA_List_Quiet TRUE
  868.       do until eof('IN')
  869.          linein=readln('IN')
  870.          if ~eof('IN') then do
  871.             list ID YTRFM INSERT POS MUIV_List_Insert_Bottom STRING linein
  872.          end
  873.       end
  874.       foo=close('IN')
  875.       button ID YTRFU ATTRS MUIA_Disabled FALSE   /* unghost UNDO button  */
  876.       list ID YTRFM ATTRS MUIA_List_Quiet FALSE
  877.       foo=close('OLD')                   /* close undo file               */
  878.       window ID YTINF close
  879.    end
  880.    else do
  881.       errmsg=_text._noredofile
  882.       Call ErrorMsg
  883.       exit
  884.    end
  885.  
  886. Return
  887.  
  888. /**************************************************************************/
  889. /*  Clear the list, reload from the NEW file, set button ghosting.        */
  890. /**************************************************************************/
  891. QUIT:
  892.  
  893.    if exists('T:YTReForm.new') then do
  894.       Address Command "Delete T:YTReForm.new QUIET"
  895.    end
  896.  
  897.    if exists('T:YTReForm.old') then do
  898.       Address Command "Delete T:YTReForm.old QUIET"
  899.    end
  900.  
  901.    window ID YTREW close
  902.  
  903. Return
  904.  
  905. /**************************************************************************/
  906. /*              Make sure YAM  and YAMTOOLS are running. Show YAM.        */
  907. /**************************************************************************/
  908. CheckYAM:
  909.  
  910.    if ~show('p','YAMTOOLS') then do
  911.       errmsg=_text._noyt
  912.       say errmsg
  913.       exit
  914.    end
  915.  
  916.    if ~show('p','YAM') then do
  917.       errmsg=_text._noyam
  918.       Call ErrorMsg
  919.       exit
  920.    end
  921.  
  922.    Address YAM 'show'                       /* uniconify YAM's screen     */  
  923.  
  924.     Address YAM 'info SCREEN'                /* get YAM's screen           */
  925.     screen=result
  926.     if screen='' then screen='Workbench'
  927.  
  928. Return
  929.  
  930. /**************************************************************************/
  931. /*              Make sure there isn't one running already.                */
  932. /**************************************************************************/
  933. CheckDup:
  934.  
  935.    list ID YTRFM ATTRS MUIA_List_Entries
  936.    if result~='RESULT' then do
  937.       errmsg=_text._secondrun
  938.       Call ErrorMsg
  939.       exit
  940.    end
  941.  
  942. Return
  943. /******************************************************************************/
  944. /*  Get information from YAM config file                                      */
  945. /******************************************************************************/
  946. GetYamInfo:
  947.  
  948.    Address YAM 'getmailinfo file'           /* find which mail to rewrap  */
  949.    mfile=result
  950.    
  951.    if mfile='' | mfile='RESULT' then do     /* no mail selected           */
  952.       errmsg=_text._nomail
  953.       Call ErrorMsg
  954.       exit
  955.    end
  956.  
  957.    WordWrap=''
  958.    QuoteText=''
  959.  
  960.    if open('IN','YAM:.config','R') then do
  961.       do until eof('IN')
  962.          linein=readln('IN')
  963.          parse var linein yamopt '=' yamval
  964.          if upper(yamopt)='WORDWRAP' then do
  965.             WordWrap=strip(yamval)
  966.             leave
  967.          end
  968.       end
  969.       foo=close('IN')
  970.    end
  971.  
  972.    if WordWrap='' then WordWrap=76
  973.  
  974. Return
  975.  
  976. /******************************************************************************/
  977. /*  Display ERROR message and EXIT.                                           */
  978. /******************************************************************************/
  979. ErrorMsg:
  980.  
  981.    window ID YTINF CLOSE
  982.  
  983.    request ID ERRM GADGETS  _text._ok errmsg
  984.  
  985.    exit
  986.  
  987. Return
  988.  
  989. /******************************************************************************/
  990. /*  Display the mail in a list window.                                        */
  991. /******************************************************************************/
  992. BuildWindow:
  993.  
  994.    if exists(UnMime.rexx) then ghostunmime=FALSE
  995.                           else ghostunmime=TRUE
  996.  
  997.    window ID YTREW TITLE _title._main,        
  998.           COMMAND '"YTReFormat.rexx QUIT"',
  999.           ATTRS MUIA_Window_PublicScreen screen
  1000.  
  1001.         group
  1002.          group HORIZ
  1003.                text ID YTRFF HELP help.YTRFF NODE node.YTRFF LABEL mfile
  1004.             string ID QTEXT ATTRS MUIA_ShowMe FALSE CONTENT QuoteText
  1005.             LABEL _text._wordwrap
  1006.             string ID RWRAP HELP help.RWRAP NODE node.RWRAP, 
  1007.                          ATTRS MUIA_Weight 10 CONTENT WordWrap
  1008.          endgroup
  1009.          group ATTRS MUIA_VertWeight 25
  1010.             list ID YTRFH INSERT ATTRS MUIA_ShowMe FALSE 
  1011.             list ID YTRFT COMMAND '"YTReFormat.rexx NEWHEAD %s"',
  1012.                  HELP help.YTRFT NODE node.YTRFT INSERT
  1013.          endgroup
  1014.          group HORIZ ATTRS MUIA_VertWeight 300
  1015.             group
  1016.                list ID YTRFM HELP help.YTRFM NODE node.YTRFM INSERT,
  1017.                      ATTRS MUIA_Listview_MultiSelect MUIV_Listview_MultiSelect_Shifted
  1018.             endgroup
  1019.             group ATTRS MUIA_HorizWeight 10
  1020.                button ID YTRFW COMMAND '"YTReFormat.rexx REWRAP"',
  1021.                             HELP help.YTRFW NODE node.YTRFW, 
  1022.                              LABEL _label._YTRFW
  1023.                button ID YTRFO COMMAND '"YTReFormat.rexx UNQUOTE"', 
  1024.                            HELP help.YTRFO NODE node.YTRFO,              
  1025.                       LABEL _label._YTRFO                           
  1026.                button ID YTRFY COMMAND '"YTReFormat.rexx STYLE"', 
  1027.                             HELP help.YTRFY NODE node.YTRFY, 
  1028.                              LABEL _label._YTRFY
  1029.                button ID YTRF3 COMMAND '"YTReFormat.rexx UNMIME"',  
  1030.                           HELP help.YTRF3 NODE node.YTRF3,               
  1031.                       ATTRS MUIA_Disabled ghostunmime,
  1032.                       LABEL _label._YTRF3                            
  1033.                space  
  1034.             endgroup
  1035.          endgroup
  1036.          group HORIZ
  1037.             button ID YTRFD COMMAND '"YTReFormat.rexx DONE"',
  1038.                         HELP help.YTRFD NODE node.YTRFD, 
  1039.                          LABEL _label._YTRFD
  1040.             button ID YTRFU COMMAND '"YTReFormat.rexx UNDO"', 
  1041.                         HELP help.YTRFU NODE node.YTRFU, 
  1042.                    ATTRS MUIA_Disabled TRUE,
  1043.                    LABEL _label._YTRFU
  1044.             button ID YTRFS COMMAND '"YTReFormat.rexx SAVE"', 
  1045.                         HELP help.YTRFS NODE node.YTRFS, 
  1046.                          LABEL _label._YTRFS
  1047.             button ID YTRFR COMMAND '"YTReFormat.rexx REDO"',
  1048.                         HELP help.YTRFR NODE node.YTRFR, 
  1049.                    ATTRS MUIA_Disabled TRUE,
  1050.                    LABEL _label._YTRFR
  1051.             button ID YTRFQ COMMAND '"YTReFormat.rexx QUIT"',
  1052.                         HELP help.YTRFQ NODE node.YTRFQ, 
  1053.                          LABEL _label._YTRFQ
  1054.          endgroup
  1055.         endgroup
  1056.  
  1057.    endwindow
  1058.  
  1059. Return
  1060.  
  1061. /******************************************************************************/
  1062. /*  Display the mail in a list window.                                        */
  1063. /******************************************************************************/
  1064. AskUser:
  1065.  
  1066.    OutQuote=''
  1067.    InnQuote=''
  1068.  
  1069.    string ID RWRAP
  1070.    WordWrap=result
  1071.  
  1072.    window ID YTUSR TITLE _title._user,
  1073.           COMMAND '"window ID YTUSR close"' PORT YAMTOOLS,
  1074.           ATTRS MUIA_Window_PublicScreen screen
  1075.  
  1076.         group HORIZ
  1077.          group 
  1078.             LABEL DOUBLE _text._outquote
  1079.             LABEL DOUBLE _text._inquote
  1080.             LABEL DOUBLE _text._wraplen
  1081.          endgroup
  1082.          group 
  1083.             string ID RUSR1 HELP help.RUSR1 NODE node.RUSR1,
  1084.                    ATTRS MUIA_CycleChain TRUE, 
  1085.                    MUIA_String_AdvanceOnCR TRUE,        
  1086.                    CONTENT OutQuote
  1087.             string ID RUSR2 HELP help.RUSR2 NODE node.RUSR2,
  1088.                    ATTRS MUIA_CycleChain TRUE, 
  1089.                    MUIA_String_AdvanceOnCR TRUE,        
  1090.                    CONTENT InnQuote
  1091.             string ID RUSR3 HELP help.RUSR3 NODE node.RUSR3,
  1092.                    ATTRS MUIA_CycleChain TRUE, 
  1093.                    MUIA_String_AdvanceOnCR TRUE,        
  1094.                    MUIA_String_Accept numerics,
  1095.                    CONTENT WordWrap
  1096.          endgroup
  1097.       endgroup
  1098.       group HORIZ
  1099.          if mainparm='REWRAP' then do
  1100.             button COMMAND '"YTReFormat.rexx DOREWRAP"' LABEL _label._YTRFW
  1101.          end
  1102.          else do
  1103.             button COMMAND '"YTReFormat.rexx DOUNQUOTE"' LABEL _label._YTRFO
  1104.          end
  1105.          button COMMAND '"window ID YTUSR close"' PORT YAMTOOLS,
  1106.                 LABEL _text._cancel
  1107.         endgroup
  1108.  
  1109.    endwindow
  1110.  
  1111.    window ID YTUSR ATTRS MUIA_Window_ActiveObject MUIV_Window_ActiveObject_Next
  1112.  
  1113. Return
  1114.  
  1115. /******************************************************************************/
  1116. /*  Display Styling window                                                    */
  1117. /******************************************************************************/
  1118. StyleWin:
  1119.  
  1120.    window ID YTSTY TITLE _title._style,
  1121.           COMMAND '"YTReFormat.rexx STYLEIT Q"',
  1122.           ATTRS MUIA_Window_PublicScreen screen
  1123.  
  1124.         group HORIZ
  1125.             group
  1126.             string ID YTSTT ATTRS MUIA_ShowMe FALSE 
  1127.             list ID YTSTM HELP help.YTSTM NODE node.YTSTM INSERT,
  1128.                  ATTRS MUIA_Listview_MultiSelect MUIV_Listview_MultiSelect_Shifted
  1129.          endgroup
  1130.             group ATTRS MUIA_HorizWeight 25
  1131.             button COMMAND '"YTReFormat.rexx STYLEIT B"',
  1132.                    HELP help.YTSTB NODE node.YTSTB,
  1133.                    LABEL _label._YTSTB
  1134.             button COMMAND '"YTReFormat.rexx STYLEIT C"', 
  1135.                    HELP help.YTSTC NODE node.YTSTC,
  1136.                    LABEL _label._YTSTC
  1137.             button COMMAND '"YTReFormat.rexx STYLEIT I"', 
  1138.                    HELP help.YTSTI NODE node.YTSTI,
  1139.                    LABEL _label._YTSTI
  1140.             button COMMAND '"YTReFormat.rexx STYLEIT U"', 
  1141.                    HELP help.YTSTU NODE node.YTSTU,
  1142.                    LABEL _label._YTSTU
  1143.             button COMMAND '"YTReFormat.rexx STYLEIT R"', 
  1144.                    HELP help.YTSTR NODE node.YTSTR,
  1145.                    LABEL _label._YTSTR
  1146.             space
  1147.          endgroup
  1148.       endgroup
  1149.       group
  1150.          string ID YTST1 COMMAND '"YTReFormat.rexx STYLEIT E"',
  1151.                 HELP help.YTST1 NODE node.YTST1
  1152.          text   ID YTST2 HELP help.YTST2 NODE node.YTST2
  1153.       endgroup
  1154.         group HORIZ
  1155.          button COMMAND '"YTReFormat.rexx STYLEIT S"',
  1156.                 HELP help.YTSTS NODE node.YTSTS,
  1157.                 LABEL _label._YTSTS
  1158.          button COMMAND '"YTReFormat.rexx STYLEIT N"', 
  1159.                 HELP help.YTSTN NODE node.YTSTN,
  1160.                 LABEL _label._YTSTN
  1161.          button COMMAND '"YTReFormat.rexx STYLEIT Q"',
  1162.                 HELP help.YTSTQ NODE node.YTSTQ,
  1163.                 LABEL _label._YTSTQ
  1164.       endgroup
  1165.  
  1166.    endwindow
  1167.  
  1168. Return
  1169.  
  1170. /******************************************************************************/
  1171. /*  Display Heading change window.                                            */
  1172. /******************************************************************************/
  1173. HeadWin:
  1174.  
  1175.    window ID YTHED TITLE _title._head,
  1176.           COMMAND '"YTReFormat.rexx HEADIT Q"',
  1177.           ATTRS MUIA_Window_PublicScreen screen
  1178.  
  1179.         group
  1180.          group HORIZ
  1181.             text ID YTHD0 HELP help.YTHD0 NODE node.YTHD0,
  1182.                  ATTRS MUIA_HorizWeight 25,
  1183.                  LABEL headtype
  1184.             space HORIZ
  1185.          endgroup
  1186.          group
  1187.             string ID YTHD1 HELP help.YTHD1 NODE node.YTHD1,
  1188.                    CONTENT oldhead
  1189.             string ID YTHD2 HELP help.YTHD2 NODE node.YTHD2,
  1190.                    CONTENT newhead
  1191.          endgroup
  1192.       endgroup
  1193.         group HORIZ
  1194.          button COMMAND '"YTReFormat.rexx HEADIT S"',
  1195.                 LABEL _text._ok
  1196.          space HORIZ
  1197.          button COMMAND '"YTReFormat.rexx HEADIT Q"',
  1198.                 LABEL _text._cancel
  1199.       endgroup
  1200.  
  1201.    endwindow
  1202.  
  1203. Return
  1204.  
  1205. /******************************************************************************/
  1206. /*  Simple information/error message window.                                  */
  1207. /******************************************************************************/
  1208. InfoWindow:
  1209.  
  1210.    window ID YTINF TITLE _title._info ATTRS MUIA_Window_PublicScreen screen,
  1211.           MUIA_Window_SizeGadget FALSE,
  1212.           MUIA_Window_DepthGadget FALSE
  1213.  
  1214.       group 
  1215.          group 
  1216.             text ID STEXT HELP help.STEXT  NODE node.STEXT LABEL infotext
  1217.          endgroup
  1218.          if showbusy then do
  1219.             group
  1220.                object CLASS '"Busy.mcc"' ATTRS MUIA_VertWeight 25
  1221.             endgroup
  1222.          end
  1223.          if infobuttons ~='' then do
  1224.             group HORIZ
  1225.                group 
  1226.                   space HORIZ 
  1227.                endgroup
  1228.                group 
  1229.                   radio ID SQUIT HELP help.SQUIT  NODE node.SQUIT LABELS infobuttons
  1230.                endgroup
  1231.                group 
  1232.                   space HORIZ 
  1233.                endgroup
  1234.             endgroup
  1235.          end
  1236.          else do
  1237.             group 
  1238.                space HORIZ 100
  1239.             endgroup
  1240.          end
  1241.       endgroup
  1242.    endwindow
  1243.  
  1244. Return
  1245.  
  1246. /******************************************************************************/
  1247. /*                      MUIREXX TAGS & VARIABLES                              */
  1248. /******************************************************************************/
  1249. Muivars:
  1250.  
  1251. MUIA_CycleChain =           0x80421ce7
  1252. MUIA_Disabled =             0x80423661
  1253. MUIA_HorizWeight =          0x80426db9
  1254. MUIA_List_Format =          0x80423c0a 
  1255. MUIA_List_Entries =         0x80421654 
  1256. MUIA_Listview_MultiSelect = 0x80427e08
  1257. MUIA_List_Quiet =           0x8042d8c7
  1258. MUIA_List_Visible =         0x8042191f
  1259. MUIA_Selected =             0x8042654b
  1260. MUIA_ShowMe =               0x80429ba8
  1261. MUIA_String_Accept =        0x8042e3e1
  1262. MUIA_VertWeight =           0x804298d0 
  1263. MUIA_Weight =               0x80421d1f 
  1264. MUIA_Window_ActiveObject =  0x80427925
  1265. MUIA_Window_DepthGadget  =  0x80421923
  1266. MUIA_Window_PublicScreen =  0x804278e4
  1267. MUIA_Window_SizeGadget  =   0x8042e33d
  1268. MUIA_String_AdvanceOnCR =   0x804226de
  1269. MUIA_Window_ActiveObject =  0x80427925
  1270.  
  1271. MUIM_List_Jump =            0x8042baab
  1272. MUIM_List_Clear =           0x8042ad89
  1273.  
  1274. TRUE=1
  1275. FALSE=0
  1276.  
  1277. MUIV_List_Insert_Active = -1
  1278. MUIV_List_Insert_Bottom = -3
  1279. MUIV_Listview_MultiSelect_Shifted = 2
  1280. MUIV_List_Remove_First =  0
  1281. MUIV_Window_ActiveObject_Next = -1
  1282.  
  1283. Return
  1284.  
  1285. /**************************************************************************/
  1286. /*           Various values used throughout the various routines          */
  1287. /**************************************************************************/
  1288. YTvars:
  1289.  
  1290. missing='.'
  1291. tab='09'x                                   /* tab character              */
  1292. numerics='"=0123456789"'                    /* valid for numeric input    */
  1293.  
  1294. wrapmin1=30                                 /* arbitrary low value        */
  1295. wrapmin2=20                                 /* arbitrary low value        */
  1296. wrapmax=79                                  /* max with LF for text/plain */
  1297.  
  1298. bo='\033b'                                  /* print control BOLD         */
  1299. bc='\033b\033c'                             /* print control BOLD CENTER  */
  1300. it='\033i'                                  /* print control ITALIC       */
  1301. ul='\033u'                                  /* print control UNDERLINED   */
  1302. co='\0335'                                  /* print control COLORED pen5 */
  1303. cx='\0332'                                  /* print control FOREGROUND   */
  1304. hl='\0338'                                  /* print control HIGHLIGHT    */
  1305. nc='\033n\033c'                             /* print control NORM CENTER  */
  1306. no='\033n'                                  /* print control NORM         */
  1307. nl='\n'                                     /* print control 1 NEW LINE   */
  1308. nl2='\n\n'                                  /* print control 2 NEW LINES  */
  1309. ct='\033c'                                  /* print control CENTER       */
  1310. lf='\033l'                                  /* print control LEFT ALIGN   */
  1311. rt='\033r'                                  /* print control RIGHT ALIGN  */
  1312.  
  1313. SansiBold=bo
  1314. EansiBold=no
  1315. SansiItal=it
  1316. EansiItal=no
  1317. SansiUlin=ul  
  1318. EansiUlin=no
  1319. SansiColr=co
  1320. EansiColr=cx
  1321. qattr=hl
  1322. qoff=EansiColr
  1323.  
  1324. stylelist='#_*/'
  1325. goodpre1=' [({\"&+'
  1326. goodpre2="'"
  1327. badpost1=' /_:;.,#+\|?=([{&%$§"!'
  1328. goodpost1=" +&'\n})]-.:,;!?"  
  1329.  
  1330. Return
  1331.  
  1332. /**************************************************************************/
  1333. /*    Messages, text, etc. constructed using previously defined values    */
  1334. /**************************************************************************/
  1335. Builtvars:
  1336.  
  1337. Return
  1338.  
  1339. /**************************************************************************/
  1340. /*               Pointers into the YamTools.guide documentation           */
  1341. /**************************************************************************/
  1342. Helpvars:
  1343.  
  1344. node.QTEXT='7.3.'
  1345. node.RUSR1='7.3.'
  1346. node.RUSR2='7.3.'
  1347. node.RUSR3='7.3.'
  1348. node.RWRAP='7.3.'
  1349. node.SQUIT='7.3.'
  1350. node.STEXT='7.3.'
  1351. node.YTRFD='7.3.'
  1352. node.YTRFF='7.3.'
  1353. node.YTRFM='7.3.'
  1354. node.YTRFO='7.3.'
  1355. node.YTRFQ='7.3.'
  1356. node.YTRFR='7.3.'
  1357. node.YTRFS='7.3.'
  1358. node.YTRFT='7.3.'
  1359. node.YTRFU='7.3.'
  1360. node.YTRFW='7.3.'
  1361. node.YTRFY='7.3.'
  1362. node.YTRF3='7.3.'
  1363.  
  1364. node.YTST1='7.3.'
  1365. node.YTST2='7.3.'
  1366. node.YTSTB='7.3.'
  1367. node.YTSTC='7.3.'
  1368. node.YTSTI='7.3.'
  1369. node.YTSTM='7.3.'
  1370. node.YTSTN='7.3.'
  1371. node.YTSTQ='7.3.'
  1372. node.YTSTR='7.3.'
  1373. node.YTSTS='7.3.'
  1374. node.YTSTU='7.3.'
  1375.  
  1376. node.YTHD0='7.3'
  1377. node.YTHD1='7.3'
  1378. node.YTHD2='7.3'
  1379.  
  1380. Return
  1381.  
  1382. /**************************************************************************/
  1383. /*       Mui Gadgets, text, msgs, etc. used in YamTools                   */
  1384. /**************************************************************************/
  1385. Localize:
  1386.  
  1387. /*********************************/
  1388. /* Miscellaneous info strings    */
  1389. /*********************************/
  1390. _title._main="""YTReFormat v1.0"""          /* main screen title          */
  1391. _title._info="""YTreFormat Info"""          /* default title on infomsg   */
  1392. _title._user="""YTReFormat User Info"""     /* title for user info screen */
  1393. _title._head="""YTreFormat Edit Header"""   /*!title for header change    */
  1394. _title._style="""YTReFormat Style"""        /* title for styling window   */
  1395.  
  1396. _text._ok="Ok"                              /* various OK buttons         */
  1397. _text._cancel="Cancel"                      /* LABEL for CANCEL button    */
  1398. _text._wordwrap="WordWrap"                  /* text for WordWrap field    */
  1399.  
  1400. _label._YTRFD="Done"                        /* label for DONE button      */
  1401. _label._YTRFU="UnDo"                        /* label for DONE button      */
  1402. _label._YTRFR="ReDo"                        /* label for DONE button      */
  1403. _label._YTRFS="Save"                        /* label for SAVE button      */
  1404. _label._YTRFQ="Quit"                        /* label for QUIT  button     */
  1405. _label._YTRFY="Style"                       /* label for STYLE button     */              
  1406. _label._YTRFO="UnQuote"                     /* label for UNQUOTE button   */
  1407. _label._YTRFW="ReWrap"                      /* label for REWRAP  button   */
  1408. _label._YTRF3="UnMime"                      /* label for UNMIME button    */
  1409.  
  1410. _label._YTSTB="Bold"                        /* label for BOLD    button   */
  1411. _label._YTSTC="Color"                       /* label for COLOR   button   */
  1412. _label._YTSTI="Italic"                      /* label for ITALIC  button   */
  1413. _label._YTSTU="ULine"                       /* label for ULINE   button   */
  1414. _label._YTSTR="Remove"                      /* label for REMOVE  button   */
  1415. _label._YTSTN="Skip"                        /* label for SKIP    button   */
  1416. _label._YTSTS="Save"                        /* label for SAVE    button   */
  1417. _label._YTSTQ="Quit"                        /* label for QUIT    button   */
  1418. _label._YTHDS="Save"                        /* label for SAVE    button   */
  1419. _label._YTHDQ="Quit"                        /* label for QUIT    button   */
  1420.  
  1421. _text._outquote="Outer Quoting:"         /* text for outer quoting prompt */
  1422. _text._inquote="Inner Quoting:"          /* text for inner quoting prompt */
  1423. _text._wraplen="Wrap Length:"            /* text for word wrap len prompt */
  1424.  
  1425. _text._doredo="Doing ReDo"                   /* doing redo message        */
  1426. _text._doundo="Doing UnDo"                   /* doing undo message        */
  1427. _text._dowrap="Doing ReWrapping"             /* doing ReWrapping message  */
  1428. _text._dounquote="Doing UnQuoting"           /* doing UnQuoting message   */
  1429. _text._savemail="Saving Mail File"           /* saving mailfile message   */
  1430. _text._procmail="Processing Mail for ReWrapping" /* processing mail msg   */
  1431.  
  1432. /*********************************/
  1433. /* Various error conditions      */
  1434. /*********************************/
  1435.  
  1436. _text._noyam="You need YAM running to use YAMTOOLS"    /* yam not running */
  1437. _text._noyt="You need YAMTOOLS running to use YTReFormat" /* no yamtools  */
  1438. _text._secondrun="You ALREADY have a YTReFormat started"  /* second run   */
  1439. _text._nomail="You need to select a mail file to use YTReFormat"
  1440.  
  1441.                                          /* not a valid file or not found */               
  1442. _text._badmail="Not a valid file selected for Rewrapping"
  1443.  
  1444. _text._noredofile="Unable to open REDO file"     /* bad redo file message */
  1445. _text._noundofile="Unable to open UNDO file"     /* bad undo file message */
  1446. _text._nolines="No lines selected for rewrapping" /* no lines selected    */
  1447. _text._noslines="No lines selected for styling"  /*  no lines selected    */
  1448.  
  1449.                   /* the word wrap is too short for the quoting requested */
  1450. _text._wwshort="Word Wrap length is too small for quoting requested"
  1451.  
  1452.                   /* word wrap length is out of valid range values        */
  1453. _text._wwoutrange="Word Wrap should be between "WRAPMIN1 "and " WRAPMAX
  1454.  
  1455.                   /* non-numeric value -- shouldn't actually happen       */
  1456. _text._wwnotnum="Word Wrap length must be a numeric value"
  1457.  
  1458.                   /* bad parm passed to program..should never happen      */
  1459. _text._badparm="Unrecognized parms passed to YTReFormat:"
  1460.  
  1461.                   /* ! message has QUOTE-PRINTABLE portions               */
  1462. _text._prtquoted="Warning! Parts of this message are in Quoted-Printable format\nYou may wish to UnMime before formatting"
  1463.  
  1464. /**************************************************************************/
  1465. /*           Help Messages to display with MUI bubble facility.           */
  1466. /*                                                                        */
  1467. /* Format is simple: help.ID where ID is the id specified on the MUI      */
  1468. /* object statement.                                                      */
  1469. /* Similar approach for accessing the .guide information using the NODE   */
  1470. /* option on the object statement.                                        */
  1471. /*                                                                        */
  1472. /**************************************************************************/
  1473.  
  1474. help.QTEXT=""""""
  1475. help.RUSR1="""Outer-most Quoting Character(s)"""
  1476. help.RUSR2="""Inner Quoting Character(s)"""
  1477. help.RUSR3="""Word Wrap length to use"""
  1478. help.RWRAP="""Word Wrap value from Yam:.config"""
  1479. help.SQUIT=""""""
  1480. help.STEXT=""""""
  1481. help.YTRFD="""Save changes to YAM mail file and Quit"""
  1482. help.YTRFF="""Yam mail file"""
  1483. help.YTRFM="""Select lines to rewrap"""
  1484. help.YTRFO="""UnQuote the selected lines"""
  1485. help.YTRFQ="""Abandon changes since last save"""
  1486. help.YTRFR="""Undo previous Undo wordwrap action"""
  1487. help.YTRFS="""Save changes to YAM mail file"""
  1488. help.YTRFT="""Short Header of mail file\nDouble-click to edit"""
  1489. help.YTRFU="""Undo previous wordwrap action"""
  1490. help.YTRFW="""ReWrap the selected lines"""
  1491. help.YTRFY="""Style the selected lines"""
  1492. help.YTRF3="""Convert mail to 8bit encoding using UnMime.rexx if available"""
  1493.  
  1494. help.YTST1="""Line being styled\nEdit and press RETURN"""
  1495. help.YTST2="""Line as it appears in YAM"""
  1496. help.YTSTB="""Apply BOLD styling to selected lines"""
  1497. help.YTSTC="""Apply COLOR styling to selected lines"""
  1498. help.YTSTI="""Apply ITALIC styling to selected lines"""
  1499. help.YTSTM="""Select Word(s) to Style"""
  1500. help.YTSTN="""Skip to next selected line without saving changes"""
  1501. help.YTSTQ="""Quit without saving this change"""
  1502. help.YTSTR="""Remove styling from selected lines"""
  1503. help.YTSTS="""Save changes and go to next selected line"""
  1504. help.YTSTU="""Apply UNDERLINE styling to selected lines"""
  1505.  
  1506. help.YTHD0="""Header type"""
  1507. help.YTHD1="""Old header"""
  1508. help.YTHD2="""Edit for new header"""
  1509.  
  1510. Return
  1511.  
  1512.