home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / comm / mail / YamTools.lha / yamtools / YAMTOOLS.rexx < prev   
OS/2 REXX Batch file  |  1997-02-25  |  78KB  |  2,105 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /*                            YAMTOOLS                                        */
  4. /*                 Copyright ©1997 by Dick Whiting                            */
  5. /*                                                                            */
  6. /*----------------------------------------------------------------------------*/
  7. /*                                                                            */
  8. /* Standard Disclaimer: I wrote it, it works for me, I don't guarantee        */
  9. /* that it will do anything productive for anyone else, etc. etc. ;-)         */
  10. /*                                                                            */
  11. /*HOWEVER, if you DO find a use for it: I homeschool my kids and they         */
  12. /*would love a postcard from where EVER you live.                             */
  13. /*                                                                            */
  14. /*Instant GEOGRAPHY lesson;)                                                  */
  15. /*                                                                            */
  16. /*                                                                            */
  17. /*POSTCARDS:    Dick Whiting                                                  */
  18. /*              28590 S. Beavercreek Rd.                                      */
  19. /*              Mulino, Oregon 97042                                          */
  20. /*              USA                                                           */
  21. /*                                                                            */
  22. /*----------------------------------------------------------------------------*/
  23. /*                                                                            */
  24. /*               Address Bug Reports or Comments to:                          */
  25. /*                Dick Whiting <dwhiting@europa.com>                          */
  26. /*                         25 February 1997                                   */
  27. /*                                                                            */
  28. /******************************************************************************/
  29. /*
  30. $VER: 1.1 Copyright ©1997 by Dick Whiting
  31. $AUTHOR: Dick Whiting
  32. $DESCRIPTION: Add-on Tools for Marcel Beck's wonderful YAM
  33. */
  34.  
  35. options results
  36. options failat 21
  37.  
  38. subrtn=''
  39. parm=''
  40. rest=''
  41.  
  42. parse arg subrtn parm rest
  43.  
  44. /******************************************************************************/
  45. /*                      MUIREXX TAGS & VARIABLES                              */
  46. /******************************************************************************/
  47.  
  48. Application_AboutMUI =      0x8042d21d
  49. Application_OpenConfigWindow = 0x804299ba
  50.  
  51. MUIA_Application_Author =   0x80424842
  52. MUIA_Application_Base =     0x8042e07a
  53. MUIA_Application_Copyright= 0x8042ef4d
  54. MUIA_Application_Description=0x80421fc6
  55. MUIA_Application_Title =    0x804281b8
  56. MUIA_Application_Version =  0x8042b33f
  57.  
  58. MUIA_Background  =          0x8042545b
  59. MUIA_CycleChain =           0x80421ce7
  60. MUIA_Disabled =             0x80423661
  61. MUIA_Draggable =            0x80420b6e 
  62. MUIA_DrawersOnly =          0x8008002F
  63. MUIA_Dropable =             0x8042fbce 
  64. MUIA_Font =                 0x8042be50
  65. MUIA_Frame  =               0x8042ac64
  66. MUIA_HorizWeight =          0x80426db9
  67. MUIA_Group_Columns =        0x8042f416
  68. MUIA_Group_SameSize =       0x80420860
  69. MUIA_List_Active =          0x8042391c 
  70. MUIA_List_DragSortable =    0x80426099
  71. MUIA_List_Entries =         0x80421654 
  72. MUIA_List_Format =          0x80423c0a 
  73. MUIA_List_InsertPosition =  0x8042d0cd
  74. MUIA_List_Quiet =           0x8042d8c7 
  75. MUIA_List_ShowDropMarks =   0x8042c6f3 
  76. MUIA_Listview_DoubleClick = 0x80424635
  77. MUIA_Listview_DragType =    0x80425cd3
  78. MUIA_Listview_MultiSelect = 0x80427e08
  79. MUIA_Listview_SelectChange= 0x8042178f 
  80. MUIA_Menuitem_Shortcut =    0x80422030 
  81. MUIA_Menuitem_Title =       0x804218be 
  82. MUIA_Selected =             0x8042654b
  83. MUIA_ShowMe =               0x80429ba8
  84. MUIA_String_AdvanceOnCR =   0x804226de
  85. MUIA_VertWeight =           0x804298d0 
  86. MUIA_Weight =               0x80421d1f 
  87. MUIA_Window_DepthGadget  =  0x80421923
  88. MUIA_Window_DragBar  =      0x8042045d
  89. MUIA_Window_ActiveObject =  0x80427925
  90. MUIA_Window_PublicScreen =  0x804278e4
  91. MUIA_Window_SizeGadget  =   0x8042e33d
  92.  
  93. MUIM_List_Clear =           0x8042ad89
  94. MUIM_List_GetEntry =        0x804280ec 
  95. MUIM_List_NextSelected =    0x80425f17
  96.  
  97. ASLFR_InitialFile =         0x80080008
  98. ASLFR_InitialDrawer =       0x80080009
  99.  
  100. TRUE=1
  101. FALSE=0
  102.  
  103. MUIV_Font_Big = -6
  104. MUIV_Frame_None  = 0
  105. MUIV_List_GetEntry_Active = -1
  106. MUIV_List_Insert_Active = -1
  107. MUIV_List_Insert_Bottom = -3
  108. MUIV_List_Insert_Top = 0
  109. MUIV_Listview_DragType_Immediate = 1
  110. MUIV_Listview_MultiSelect_Shifted = 2
  111. MUII_WindowBack  = 0
  112. MUIV_Window_ActiveObject_Next = -1
  113.  
  114. /**************************************************************************/
  115. /*           Various values used throughout the various routines          */
  116. /**************************************************************************/
  117. aboutlist=TRUE                              /* show list in about window  */
  118. comma=','                                   /* used in string building    */
  119. configheader='YamTools Configuration File -- Copyright by Dick Whiting'
  120. delaytm=20                                  /* wait time per loop         */
  121. emptyconfig='empty'||comma||'none'||comma||'<----available---->' 
  122. fontsize=''                                 /* used to change FONT size   */
  123. infolines=28                                /* number of header lines     */
  124. infotitle="YAM Tools Info"                  /* default title on infomsg   */
  125. maxarchs=50000                              /* very large number for loop */
  126. missing='.'                                 /* indicate missing value     */
  127. showbusy=FALSE                              /* don't show busy indicator  */
  128. shutdown=FALSE                              /* flag for quitting YAMTOOLS */
  129. timestamp=time('S')                         /* timestamp for temp files   */
  130. goodconfig=TRUE                             /* assume config good         */
  131.  
  132. /**************************************************************************/
  133. /*           Help Messages to display with MUI bubble facility.           */
  134. /*                                                                        */
  135. /* Format is simple: help.ID where ID is the id specified on the MUI      */
  136. /* object statement.                                                      */
  137. /* Similar approach for accessing the .guide information using the NODE   */
  138. /* option on the object statement.                                        */
  139. /*                                                                        */
  140. /**************************************************************************/
  141.  
  142. help.ALST='"Select Folders to search\nor run ARexx Program against"'
  143. help.ARLD='"Use to load/reload folder list\nRequired if you add\nor delete folders"'
  144. help.B00= '"Executes ARexx Program defined in Configuration"'
  145. help.CFG4='"Save & Use currently defined configuration to file"'
  146. help.CFG5='"Use currently defined configuration"'
  147. help.CFG6='"Reload & Use last SAVED/LOADED configuration file"'
  148. help.CFG7='"Clear Selected Entry\n(Remove Script)"'
  149. help.CFG9='"Undo LAST edited entry in list"'
  150. help.CFG1='"Label to appear on button"'
  151. help.CFG2='"Type of processing to do\n- See Documentation or press HELP"'
  152. help.CFG3='"ARexx program to execute when button is pressed"'
  153. help.CFGF='"Location of FlashFind program - required"'
  154. help.CFGM='"Current Mail Directory YAM is using - required"'
  155. help.CFGQ='"Location of QuickSort program - required"'
  156. help.CLST='"Double click to edit entry\nDrag&Drop to Sort"'
  157. help.MDIR='"Currently defined Mail Directory - change on Config page"'
  158. help.MLST='"Double click to READ\nSelect for ARexx Execution target"'
  159. help.SLOG='"Match Any (OR logic)\nMatch All (AND logic)\nfor mail searching"'
  160. help.SQUIT='"INTERRUPT will show results upto this point\nABORT stops ALL processing"'
  161. help.SRC1='"Enter strings to Search for"'
  162. help.SRC2='"Enter strings to Search for"'
  163. help.SRC3='"Enter strings to Search for"'
  164. help.SRCA='"Searches in ALL lines of mail for search strings"'
  165. help.SRCF='"Searches From: Reply-To: Sender:\nlines in mail for search strings"'
  166. help.SRCM='"Searches NON-header\nlines in mail for search strings"'
  167. help.SRCS='"Searches Subject:\nlines in mail for search strings"'
  168. help.SRCT='"Searches To: CC:\nlines in mail for search strings"'
  169. help.SRCX='"Start the Search"'
  170. help.STEXT='"Information Message\nRead it;)"'
  171.  
  172. /**************************************************************************/
  173. /*               Pointers into the YamTools.guide documentation           */
  174. /**************************************************************************/
  175. node.ALST='4.1.'
  176. node.ARLD='4.1.'
  177. node.B00='6.2.'
  178. node.CFG4='6.2.'
  179. node.CFG5='6.2.'
  180. node.CFG6='6.2.'
  181. node.CFG7='6.2.'
  182. node.CFG9='6.2.'
  183. node.CFG1='6.2.'
  184. node.CFG2='6.2.'
  185. node.CFG3='6.2.'
  186. node.CFGF='6.1.'
  187. node.CFGM='6.1.'
  188. node.CFGQ='6.1.'
  189. node.CLST='6.2.'
  190. node.MDIR='6.1.'
  191. node.MLST='5.1.'
  192. node.SLOG='4.3.'
  193. node.SQUIT='7.2.'
  194. node.SRC1='4.3.'
  195. node.SRC2='4.3.'
  196. node.SRC3='4.3.'
  197. node.SRCA='4.3.'
  198. node.SRCF='4.3.'
  199. node.SRCM='4.3.'
  200. node.SRCS='4.3.'
  201. node.SRCT='4.3.'
  202. node.SRCX='4.3.'
  203. node.STEXT='7.2.'
  204.  
  205. /**************************************************************************/
  206. /*                                                                        */
  207. /*                       Main Logic Routine                               */
  208. /*                                                                        */
  209. /**************************************************************************/
  210.  
  211. Address YAMTOOLS
  212.  
  213. Call CheckYam                               /* No YAM-no sense running    */
  214.  
  215. getvar YAMTOOLSDEBUG                         /* see if we're debugging     */ 
  216. debug=result
  217. if debug~=TRUE then debug=FALSE
  218.  
  219. if debug then say 'subrtn='subrtn 
  220. if debug then say 'parm='parm
  221. if debug then say 'rest='rest
  222.  
  223. Select
  224.    when subrtn=''   then do                 /* first time - setup window  */
  225.       Call BuildWindow
  226.       Call LoadConfig
  227.       Call EnsureLibs
  228.       Call ValidateConfig
  229.       if goodconfig then do                 /* found a valid config-use it*/ 
  230.          Call GetArchList                   /* get all folder info        */
  231.          Call ExpandAssigns                 /* change assigns to vols     */ 
  232.          Call GetVolume                     /* change devs to vols        */
  233.          Call CheckArchs                    /* make sure all exist        */
  234.          Call LoadArchList                  /* build & show folder list   */     
  235.          window ID YTINF CLOSE              /* close info window          */
  236.       end
  237.       else do                               /* invalid or not found       */
  238.          group ID YTPGS LABELS 'Config'
  239.          errmsg='Configuration File not Found or has errors\nPlease enter information\nand SAVE'
  240.          Call ErrorMsg 
  241.       end
  242.    end
  243.    when subrtn='RESCAN' then do             /* reload folder list         */
  244.       Call ClrArchList                      /* clear list in preparation  */
  245.       Call GetArchList                      /* get all folder info        */
  246.       Call ExpandAssigns                    /* change assigns to vols     */
  247.       Call GetVolume                        /* change devs to vols        */
  248.       Call CheckArchs                       /* make sure all exist        */
  249.       Call LoadArchList                     /* build & show folder list   */
  250.       window ID YTINF CLOSE                 /* close info window          */
  251.    end
  252.    when subrtn='SETALL'   then Call SetAllCheck      /* toggle checkmarks */
  253.    when subrtn='READMAIL' then Call ReadMail         /* read selected mail*/  
  254.    when subrtn='BUTTON'   then Call DoRexxButton     /* execute a button  */
  255.    when subrtn='CONFIGEDIT' then Call ConfigEdit     /* modify config     */
  256.    when subrtn='ABOUT'  then Call AboutProgs         /* show About info   */
  257.    when subrtn='LISTMAIL' then Call ListMail         /* all mail in folder*/  
  258.    when subrtn='SEARCH' then Call SearchArchs        /* do the searches   */  
  259.    otherwise nop                                     /* never happen ;)   */
  260. end
  261.  
  262. exit
  263.  
  264. /******************************************************************************/
  265. /*                      MUIREXX WINDOW DEFINITION                             */
  266. /******************************************************************************/
  267. BuildWindow:
  268.  
  269. window ID YTWIN COMMAND '"quit"' PORT YAMTOOLS TITLE '"YAM Tools"',
  270.    ATTRS MUIA_Window_PublicScreen screen
  271.    menu LABEL '"Project"'
  272.       menu LABEL '"About..."'
  273.          item COMMAND '"YamTools.rexx ABOUT YAMTOOLS"' LABEL '"YamTools"'
  274.          item COMMAND '"YamTools.rexx ABOUT YAM"' LABEL '"YAM"'
  275.          item COMMAND '"YamTools.rexx ABOUT MUIREXX"' LABEL '"MuiRexx"'
  276.          item COMMAND '"method 'Application_AboutMUI' 0"' PORT YAMTOOLS LABEL '"MUI"'
  277.       endmenu
  278.       item ATTRS MUIA_Menuitem_Title '-1'
  279.       menu LABEL '"Settings"'
  280.           item COMMAND '"method 'Application_OpenConfigWindow'"' PORT YAMTOOLS LABEL '"MUI..."'
  281.       endmenu
  282.       item ATTRS MUIA_Menuitem_Title '-1'
  283.       item COMMAND '"YamTools.rexx CONFIGEDIT SAVE"' ATTRS MUIA_Menuitem_Shortcut 'S' LABEL '"Save"'
  284.       item COMMAND '"YamTools.rexx CONFIGEDIT SAVEAS"' ATTRS MUIA_Menuitem_Shortcut 'W' LABEL '"SaveAs..."'
  285.       item COMMAND '"YamTools.rexx CONFIGEDIT READ"' ATTRS MUIA_Menuitem_Shortcut 'O' LABEL '"Open..."'
  286.       item ATTRS MUIA_Menuitem_Title '-1'
  287.       item COMMAND '"quit"' PORT YAMTOOLS ATTRS MUIA_Menuitem_Shortcut 'Q' LABEL '"Quit"'
  288.    endmenu
  289.    group ID YTPGS LABELS '"Folder List,Mail List,Config"' REGISTER
  290.  
  291. /* Folder List Page */
  292.       group 
  293.          group HORIZ
  294.             group
  295.                label DOUBLE '"Mail Directory:"'
  296.             endgroup
  297.             group
  298.                text ID MDIR HELP help.MDIR NODE node.MDIR
  299.             endgroup
  300.          endgroup
  301.          group HORIZ MUIA_VertWeight 200 MUIA_HorizWeight 100
  302.             group 
  303.                list ID ALST TITLE '"\033bYam Folder,\033bCount,,"',
  304.                   COMMAND '"YamTools.rexx LISTMAIL %s"' HELP help.ALST NODE node.ALST,
  305.                   INSERT NODUP ATTRS MUIA_Listview_MultiSelect MUIV_Listview_MultiSelect_Shifted,
  306.                   MUIA_List_Format '"MAXWIDTH=75 MINWIDTH=-1 WEIGHT=75 P=\033l BAR,MAXWIDTH=25 MINWIDTH=-1 WEIGHT=25 P=\033r,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0"'
  307.                button ID ARLD COMMAND '"YamTools.rexx RESCAN"',
  308.                       HELP help.ARLD NODE node.ARLD PRESS LABEL "Load Folder List"
  309.             endgroup
  310.             group FRAME MUIA_HorizWeight 100
  311.                group HORIZ 
  312.                   group 
  313.                      label DOUBLE '"\033lSearch SUBJECT Lines:"'
  314.                      label DOUBLE '"\033lSearch FROM Lines:"'
  315.                      label DOUBLE '"\033lSearch TO   Lines:"'
  316.                      label DOUBLE '"\033lSearch TEXT Lines:"'
  317.                      label DOUBLE '"\033lSearch ALL  LINES:"'
  318.                   endgroup
  319.                   group
  320.                      check ID SRCS COMMAND '"YamTools.rexx SETALL SRCS"', 
  321.                            HELP help.SRCS NODE node.SRCS ATTRS MUIA_Selected FALSE
  322.                      check ID SRCF COMMAND '"YamTools.rexx SETALL SRCF"', 
  323.                            HELP help.SRCF NODE node.SRCF ATTRS MUIA_Selected FALSE
  324.                      check ID SRCT COMMAND '"YamTools.rexx SETALL SRCT"', 
  325.                            HELP help.SRCT NODE node.SRCT ATTRS MUIA_Selected FALSE
  326.                      check ID SRCM COMMAND '"YamTools.rexx SETALL SRCM"', 
  327.                            HELP help.SRCM NODE node.SRCM ATTRS MUIA_Selected FALSE
  328.                      check ID SRCA COMMAND '"YamTools.rexx SETALL SRCA"', 
  329.                            HELP help.SRCA NODE node.SRCA ATTRS MUIA_Selected TRUE 
  330.                   endgroup
  331.                endgroup
  332.                group 
  333.                   group HORIZ
  334.                      group
  335.                         radio ID SLOG HELP help.SLOG NODE node.SLOG,
  336.                               LABELS '"Match Any,Match All"'
  337.                      endgroup
  338.                   endgroup
  339.                   group 
  340.                      space HORIZ 150
  341.                      label  '"\033l\033bEnter Search Strings:"'
  342.                      string ID SRC1 HELP help.SRC1 NODE node.SRC1, 
  343.                             ATTRS MUIA_CycleChain TRUE, 
  344.                             MUIA_String_AdvanceOnCR TRUE,        
  345.                             CONTENT ''
  346.                      string ID SRC2 HELP help.SRC2 NODE node.SRC2,
  347.                             ATTRS MUIA_CycleChain TRUE,
  348.                             MUIA_String_AdvanceOnCR TRUE,        
  349.                             CONTENT ''
  350.                      string ID SRC3 HELP help.SRC3 NODE node.SRC3,
  351.                             ATTRS MUIA_CycleChain TRUE,
  352.                             MUIA_String_AdvanceOnCR TRUE,        
  353.                             CONTENT ''
  354.                   endgroup
  355.                   group
  356.                      button ID SRCX HELP help.SRCX NODE node.SRCX,
  357.                             COMMAND '"YamTools.rexx SEARCH"', 
  358.                             PRESS ATTRS MUIA_CycleChain TRUE MUIA_Disabled FALSE,
  359.                             LABEL 'Search'
  360.                   endgroup
  361.                endgroup
  362.             endgroup
  363.          endgroup
  364.       endgroup
  365.  
  366. /* Mail List Page */
  367.       group ATTRS MUIA_HorizWeight 100
  368.          list ID MLST COMMAND '"YamTools.rexx READMAIL %s"', 
  369.             HELP help.MLST NODE node.MLST,
  370.             TITLE '"\033bYam Folder,\033bFrom,\033bSubject,\033bTo:,,,"',
  371.             INSERT NODUP ATTRS MUIA_Listview_MultiSelect MUIV_Listview_MultiSelect_Shifted,
  372.             MUIA_List_Format '"BAR,BAR,BAR,,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0"'
  373.       endgroup
  374.  
  375. /* Configuration Page */
  376.       group 
  377.          group FRAME 
  378.             group HORIZ
  379.                group
  380.                    label DOUBLE '\033b\033lMail Directory:'
  381.                endgroup
  382.                group
  383.                    popasl ID CFGM HELP help.CFGM NODE node.CFGM,
  384.                          ATTRS MUIA_DrawersOnly TRUE,
  385.                          MUIA_CycleChain TRUE, 
  386.                          MUIA_String_AdvanceOnCR TRUE
  387.                      endgroup
  388.             endgroup
  389.             group HORIZ
  390.                group 
  391.                    label DOUBLE '\033b\033lFlashFind:'
  392.                 endgroup
  393.                 group
  394.                    popasl ID CFGF HELP help.CFGF NODE node.CFGF,
  395.                          ATTRS MUIA_CycleChain TRUE, 
  396.                          MUIA_String_AdvanceOnCR TRUE
  397.                 endgroup
  398.                 group
  399.                    label DOUBLE '\033b\033lQuickSort:'
  400.                 endgroup
  401.                 group
  402.                    popasl ID CFGQ HELP help.CFGQ NODE node.CFGQ,
  403.                          ATTRS MUIA_CycleChain TRUE, 
  404.                          MUIA_String_AdvanceOnCR TRUE
  405.                 endgroup
  406.             endgroup
  407.          endgroup
  408.          group HORIZ 
  409.             group ATTRS MUIA_HorizWeight 300 MUIA_VertWeight 200
  410.                list ID CLST TITLE '"\033bLabel,\033bType,\033bCommand"',
  411.                   HELP help.CLST NODE node.CLST,
  412.                   DROP INSERT PRESS COMMAND '"YamTools.rexx CONFIGEDIT EDIT %s"',
  413.                   ATTRS MUIA_Listview_DragType MUIV_Listview_DragType_Immediate, 
  414.                      MUIA_List_DragSortable TRUE MUIA_List_ShowDropMarks TRUE,
  415.                      MUIA_Listview_DoubleClick TRUE,
  416.                      MUIA_List_Format '"BAR,BAR,"'
  417.             endgroup
  418.             group 
  419.                button ID CFG4 COMMAND '"YamTools.rexx CONFIGEDIT SAVE"',
  420.                       HELP help.CFG4 NODE node.CFG4 PRESS LABEL 'SAVE'
  421.                button ID CFG5 COMMAND '"YamTools.rexx CONFIGEDIT USE"',
  422.                       HELP help.CFG5 NODE node.CFG5 PRESS LABEL 'USE'
  423.                button ID CFG6 COMMAND '"YamTools.rexx CONFIGEDIT RELOAD"',
  424.                       HELP help.CFG6 NODE node.CFG6 PRESS LABEL 'RELOAD'
  425.                space
  426.                button ID CFG7 COMMAND '"YamTools.rexx CONFIGEDIT CLEAR"',
  427.                       HELP help.CFG7 NODE node.CFG7 PRESS LABEL 'CLEAR'
  428.                button ID CFG9 COMMAND '"YamTools.rexx CONFIGEDIT UNDO"',
  429.                       HELP help.CFG9 NODE node.CFG9 PRESS LABEL 'UNDO'
  430.             endgroup
  431.          endgroup
  432.          group FRAME
  433.             group HORIZ
  434.                group
  435.                   label DOUBLE '\033bLabel:'
  436.                endgroup
  437.                group
  438.                   string ID CFG1 COMMAND '"YamTools.rexx CONFIGEDIT UPDATE"',
  439.                          HELP help.CFG1 NODE node.CFG1,
  440.                          ATTRS MUIA_CycleChain TRUE,
  441.                          MUIA_String_AdvanceOnCR TRUE,
  442.                          CONTENT ''
  443.                endgroup
  444.                group
  445.                   label DOUBLE '\033bType:'
  446.                endgroup
  447.                group
  448.                   cycle ID CFG2 COMMAND '"YamTools.rexx CONFIGEDIT UPDATE"', 
  449.                         HELP help.CFG2 NODE node.CFG2,
  450.                         ATTRS MUIA_CycleChain TRUE,                            
  451.                         MUIA_String_AdvanceOnCR TRUE,
  452.                         LABELS 'Mail,Folder'
  453.                endgroup
  454.             endgroup
  455.             group HORIZ
  456.                group
  457.                   label DOUBLE '\033b\033lARexx:'
  458.                endgroup   
  459.                group
  460.                   popasl ID CFG3 COMMAND '"YamTools.rexx CONFIGEDIT UPDATE"', 
  461.                          HELP help.CFG3 NODE node.CFG3,
  462.                          ATTRS MUIA_CycleChain TRUE,
  463.                          MUIA_String_AdvanceOnCR TRUE,
  464.                          CONTENT 'YAM:REXX'
  465.                endgroup
  466.             endgroup   
  467.          endgroup 
  468.       endgroup 
  469.    endgroup
  470.  
  471. /* Command Buttons */
  472.    group FRAME ATTRS MUIA_Group_Columns 6
  473.       button ID B01 COMMAND '"YamTools.rexx BUTTON 01"' PRESS HELP help.B00 NODE node.B00
  474.       button ID B02 COMMAND '"YamTools.rexx BUTTON 02"' PRESS HELP help.B00 NODE node.B00
  475.       button ID B03 COMMAND '"YamTools.rexx BUTTON 03"' PRESS HELP help.B00 NODE node.B00
  476.       button ID B04 COMMAND '"YamTools.rexx BUTTON 04"' PRESS HELP help.B00 NODE node.B00
  477.       button ID B05 COMMAND '"YamTools.rexx BUTTON 05"' PRESS HELP help.B00 NODE node.B00
  478.       button ID B06 COMMAND '"YamTools.rexx BUTTON 06"' PRESS HELP help.B00 NODE node.B00
  479.       button ID B07 COMMAND '"YamTools.rexx BUTTON 07"' PRESS HELP help.B00 NODE node.B00
  480.       button ID B08 COMMAND '"YamTools.rexx BUTTON 08"' PRESS HELP help.B00 NODE node.B00
  481.       button ID B09 COMMAND '"YamTools.rexx BUTTON 09"' PRESS HELP help.B00 NODE node.B00
  482.       button ID B10 COMMAND '"YamTools.rexx BUTTON 10"' PRESS HELP help.B00 NODE node.B00
  483.       button ID B11 COMMAND '"YamTools.rexx BUTTON 11"' PRESS HELP help.B00 NODE node.B00
  484.       button ID B12 COMMAND '"YamTools.rexx BUTTON 12"' PRESS HELP help.B00 NODE node.B00
  485.       button ID B13 COMMAND '"YamTools.rexx BUTTON 13"' PRESS HELP help.B00 NODE node.B00
  486.       button ID B14 COMMAND '"YamTools.rexx BUTTON 14"' PRESS HELP help.B00 NODE node.B00
  487.       button ID B15 COMMAND '"YamTools.rexx BUTTON 15"' PRESS HELP help.B00 NODE node.B00
  488.       button ID B16 COMMAND '"YamTools.rexx BUTTON 16"' PRESS HELP help.B00 NODE node.B00
  489.       button ID B17 COMMAND '"YamTools.rexx BUTTON 17"' PRESS HELP help.B00 NODE node.B00
  490.       button ID B18 COMMAND '"YamTools.rexx BUTTON 18"' PRESS HELP help.B00 NODE node.B00
  491.    endgroup
  492. endwindow
  493.  
  494. application ATTRS MUIA_Application_Author '"Dick Whiting"', 
  495.             MUIA_Application_Base '"YAMTOOLS"',
  496.             MUIA_Application_Copyright '"Copyright ©1997 by Dick Whiting"',
  497.             MUIA_Application_Description '" Add-On Tools For YAM"',
  498.             MUIA_Application_Title '"YamTools"',
  499.             MUIA_Application_Version '"Version 1.0beta"'
  500.  
  501. Return
  502.  
  503. /**************************************************************************/
  504. /*              Make sure YAM is running & visible.                       */
  505. /**************************************************************************/
  506. CheckYAM:
  507.  
  508.    if ~show('p','YAM') then do
  509.       errmsg='You need YAM running to use YAMTOOLS'
  510.       if subrtn='' then do
  511.          shutdown=TRUE
  512.       end
  513.       else do
  514.          shutdown=FALSE
  515.       end
  516.       Call ErrorMsg  
  517.    end
  518.  
  519.    Address YAM 'show'                       /* uniconify YAM's screen     */  
  520.  
  521.     Address YAM 'info SCREEN'                /* get YAM's screen           */
  522.     screen=result
  523.  
  524. Return
  525.  
  526. /**************************************************************************/
  527. /*                                                                        */
  528. /*              Make sure that we have all the libs we need:              */
  529. /*                               RexxSupport                              */
  530. /*                               QuickSort                                */
  531. /*                                                                        */
  532. /**************************************************************************/
  533. EnsureLibs:
  534.  
  535.    if ~show('L','rexxsupport.library') then do
  536.       addlib('rexxsupport.library',0,-30)
  537.    end
  538.  
  539.    if ~show('p','QuickSortPort') then do
  540.       address Command "run >nil: "qsortprog
  541.       do i = 1 to 10
  542.          if ~show('p','QuickSortPort') then foo=delay(delaytm)
  543.          else leave i
  544.       end
  545.    end
  546.    if show('p','QuickSortPort') then do
  547.       call addlib('QuickSortPort',-30)
  548.    end
  549.    else do
  550.       errmsg='Unable to find QuickSort -- check installation instructions'
  551.       signal ErrorMsg
  552.    end
  553.  
  554. Return
  555.  
  556. /**************************************************************************/
  557. /*              Expand Assign Names for YAM folders                       */
  558. /*                                                                        */
  559. /*  FlashFind reports back on the volume:directory/subdir/file so to make */
  560. /*  sure we can accurately identify and match files, we'll change assigns */
  561. /*  to this format.                                                       */
  562. /*                                                                        */
  563. /**************************************************************************/
  564. ExpandAssigns:
  565.  
  566.    assign.=missing
  567.    assign.0=0
  568.  
  569.    assignfile='T:YTassigns.'||timestamp
  570.  
  571.    text ID MDIR 
  572.    maildir=result
  573.    if maildir='' then do
  574.       errmsg='You MUST set Mail Directory in Configuration'
  575.       signal ErrorMsg 
  576.    end
  577.  
  578.    Address Command "assign > "assignfile
  579.    foo=delay(delaytm*3)
  580.    goodopen=open('IN',assignfile,'R')
  581.    if goodopen then do 
  582.       do until eof('IN')
  583.          linein=readln('IN')
  584.          if pos('Directories:',linein)>0 then do
  585.             do until eof('IN') 
  586.                linein=readln('IN')
  587.                if linein='' then signal CloseAssign
  588.                assign.0=1+assign.0
  589.                aptr=assign.0
  590.                assign.aptr=word(linein,1)
  591.                assign.aptr.1=word(linein,2)
  592.             end
  593.          end
  594.       end
  595.    end
  596.    else do 
  597.       errmsg='Couldnt open assignfile: 'assignfile  
  598.       Call ErrorMsg
  599.    end
  600.  
  601. CloseAssign:
  602.  
  603.    result=close('IN')
  604.  
  605.    if pos(':',maildir)>0 then do
  606.       testvol=substr(maildir,1,pos(':',maildir)-1)
  607.       restvol=substr(maildir,pos(':',maildir)+1)
  608.       do j=1 to assign.0
  609.          if upper(assign.j)=upper(testvol) then do 
  610.             maildir=assign.j.1
  611.             if right(maildir,1)~=':' then do 
  612.                if restvol~='' then maildir=maildir||'/'||restvol
  613.             end
  614.             leave j
  615.          end
  616.       end
  617.    end
  618.  
  619.    do i=1 to finfo.0
  620.       if pos(':',finfo.i.1.1)>0 then do
  621.          testvol=substr(finfo.i.1.1,1,pos(':',finfo.i.1.1)-1)
  622.          restvol=substr(finfo.i.1.1,pos(':',finfo.i.1.1)+1)
  623.          do j=1 to assign.0
  624.             if upper(assign.j)=upper(testvol) then do 
  625.                testvol=assign.j.1
  626.                if right(testvol,1)~=':' then do 
  627.                   if restvol~='' then testvol=testvol||'/'||restvol
  628.                end
  629.                finfo.i.1.1=testvol
  630.                leave j
  631.             end
  632.          end
  633.       end
  634.       else do
  635.          if right(maildir,1)=':' then finfo.i.1.1=maildir||finfo.i.1.1
  636.          else finfo.i.1.1=maildir||'/'||finfo.i.1.1
  637.       end
  638.    end
  639.  
  640.     if exists(assignfile) then do
  641.         Address Command 'Delete 'assignfile 'QUIET'
  642.    end
  643.  
  644. Return
  645.  
  646. /**************************************************************************/
  647. /*              Change DEV names to VOLUME names                          */
  648. /*                                                                        */
  649. /*  FlashFind reports back on the volume:directory/subdir/file so to make */
  650. /*  sure we can accurately identify and match files, we'll change device  */
  651. /*  names to volume names.                                                */
  652. /*                                                                        */
  653. /**************************************************************************/
  654. GetVolume:
  655.  
  656.    volume.=missing
  657.    volume.0=0
  658.  
  659.    volumefile='T:YTvolumes.'||timestamp
  660.  
  661.    Address Command "info > "volumefile
  662.    foo=delay(delaytm*3)
  663.    goodopen=open('IN',volumefile,'R')
  664.    if goodopen then do 
  665.       do until eof('IN')
  666.          linein=readln('IN')
  667.          if word(linein,1)='Unit' then do
  668.             do until eof('IN') 
  669.                linein=readln('IN')
  670.                if linein='' then signal CloseVolume
  671.                volume.0=1+volume.0
  672.                vptr=volume.0
  673.                volume.vptr=word(linein,1)
  674.                if words(linein)>=8 then do
  675.                   volume.vptr.1=subword(linein,8)
  676.                end
  677.             end
  678.          end
  679.       end
  680.    end
  681.    else do 
  682.       errmsg='Couldnt open volumefile: 'volumefile
  683.       Call ErrorMsg
  684.    end
  685.  
  686. CloseVolume:
  687.  
  688.    result=close('IN')
  689.  
  690.    do i=1 to finfo.0
  691.       if pos(':',finfo.i.1.1)>0 then do
  692.          testvol=substr(finfo.i.1.1,1,pos(':',finfo.i.1.1)-1)
  693.          restvol=substr(finfo.i.1.1,pos(':',finfo.i.1.1)+1)
  694.          do j=1 to volume.0
  695.             if upper(volume.j)=upper(testvol) then do 
  696.                testvol=volume.j.1
  697.                if right(testvol,1)~=':' then do 
  698.                   if restvol~='' then testvol=testvol||'/'||restvol
  699.                end
  700.                finfo.i.1.1=testvol
  701.                leave j
  702.             end
  703.          end
  704.       end
  705.       else do
  706.          if right(maildir,1)=':' then finfo.i.1.1=maildir||finfo.i.1.1
  707.          else finfo.i.1.1=maildir||'/'||finfo.i.1.1
  708.       end
  709.    end
  710.  
  711.     if exists(volumefile) then do
  712.         Address Command 'Delete 'volumefile 'QUIET'
  713.    end
  714.  
  715. Return
  716.  
  717. /******************************************************************************/
  718. /*                                                                            */
  719. /* Make sure that all of the folders actually exist as directories.           */
  720. /* They might NOT if the user sets the wrong MAILDIR: in the configuration.   */
  721. /*                                                                            */
  722. /******************************************************************************/
  723. CheckArchs:
  724.  
  725.    do i=1 to finfo.0
  726.       if ~exists(finfo.i.1.1) then do
  727.          errmsg='"One of more folders do not exist as directory names.\nCheck that MailDir is specified correctly and reload Folder list"'
  728.          shutdown=FALSE
  729.          window ID YTINF CLOSE
  730.          Call ErrorMsg
  731.       end
  732.    end
  733.  
  734.  
  735. Return
  736.  
  737. /******************************************************************************/
  738. /*                                                                            */
  739. /* Ask YAM for each folder name, its number, and its path.                    */
  740. /* Remember to set folder back to original before leaving.                    */
  741. /*                                                                            */
  742. /******************************************************************************/
  743. GetArchList:
  744.  
  745.    infotext='Getting Folder List'
  746.    infobuttons=''
  747.    showbusy=TRUE
  748.    Call InfoWindow
  749.  
  750.    Address YAM 'getfolderinfo number'
  751.    origfolder=result
  752.  
  753.    idx=0
  754.    Do i=0 to maxarchs
  755.       Address YAM 'setfolder ' i
  756.       sfrc=rc
  757.       if sfrc=0 then do
  758.          idx=i+1
  759.          Address YAM 'getfolderinfo number'
  760.          finfo.idx=result
  761.          Address YAM 'getfolderinfo name'
  762.          finfo.idx.1=result
  763.          Address YAM 'getfolderinfo path'
  764.          finfo.idx.1.1=result
  765.          Address YAM 'getfolderinfo max'
  766.          finfo.idx.1.1.1=result
  767.       end
  768.       else leave i
  769.    end
  770.    finfo.0=idx
  771.    Address YAM 'setfolder ' origfolder
  772.  
  773. Return
  774.  
  775. /******************************************************************************/
  776. /*                      Read Config File                                      */
  777. /* If the config file is not found then use internal defaults, force user to  */
  778. /* config page, and pop up message to edit and save. If the default config    */
  779. /* file is found then use it and scan archive list. Save the name as a var    */
  780. /* whenever a new file is loaded for reference by future SAVE,RELOAD cmds.    */
  781. /*                                                                            */
  782. /******************************************************************************/
  783. LoadConfig:
  784.  
  785.    if debug then say 'entered LoadConfig parm='parm
  786.  
  787.    if parm='' then configfile='YAM:REXX/YamTools.config'
  788.               else configfile=parm 
  789.  
  790.    setvar YAMTOOLSCONFIG configfile
  791.  
  792.    config.=missing
  793.    config.0=0
  794.    goodconfig=TRUE
  795.    maildir=missing
  796.    scanprog=missing
  797.    qsortprog=missing
  798.  
  799.    goodopen=open('IN',configfile,'R')
  800.    if goodopen then do 
  801.       linein=readln('IN')
  802.       if linein~=configheader then do
  803.          infomsg='This is NOT a YamTools Configuration File\nSelect one that is:)'
  804.          Call InfoMsg
  805.          result=close('IN')
  806.          goodconfig=FALSE
  807.          getvar OLDYTCONFIG 
  808.          configfile=result
  809.          setvar YAMTOOLSCONFIG configfile
  810.          signal LoadConfigEnd
  811.       end
  812.       do until eof('IN')
  813.          linein=readln('IN')
  814.          linein=strip(linein)
  815.          select 
  816.             when substr(linein,1,2)='/*' then iterate
  817.             when linein='' then iterate
  818.             when upper(word(linein,1))='MAILDIR' then maildir=word(linein,2)
  819.             when upper(word(linein,1))='SCANPROG' then scanprog=word(linein,2)
  820.             when upper(word(linein,1))='QSORTPROG' then qsortprog=word(linein,2)
  821.             otherwise do
  822.                config.0=1+config.0
  823.                cptr=config.0
  824.                parse var linein config.cptr ',' config.cptr.1 ',' config.cptr.1.1 
  825.             end
  826.          end
  827.       end
  828.       result=close('IN')
  829.    end
  830.    else do 
  831.       maildir='YAM:'
  832.       scanprog='C:FlashFind'
  833.       qsortprog='SYS:Rexxc/QuickSort'
  834.       text   ID MDIR LABEL   maildir
  835.       popasl ID CFGM CONTENT maildir
  836.       popasl ID CFGF CONTENT scanprog
  837.       popasl ID CFGQ CONTENT qsortprog
  838.       do i=0 to 17
  839.          list ID CLST INSERT POS MUIV_List_Insert_Bottom STRING emptyconfig
  840.       end 
  841.       list ID CLST POS MUIV_List_Insert_Top STRING emptyconfig
  842.       goodconfig=FALSE
  843.       signal LoadConfigEnd
  844.    end
  845.  
  846.    if maildir=missing then do
  847.       maildir='YAM:'
  848.       text   ID MDIR LABEL   maildir
  849.       popasl ID CFGM CONTENT maildir     
  850.       goodconfig=FALSE
  851.       signal LoadConfigEnd
  852.    end   
  853.    else do
  854.       text   ID MDIR LABEL   maildir
  855.       popasl ID CFGM CONTENT maildir     
  856.    end
  857.  
  858.    if scanprog=missing then do
  859.       scanprog='C:FlashFind'
  860.       popasl ID CFGF CONTENT scanprog
  861.       goodconfig=FALSE
  862.       signal LoadConfigEnd
  863.    end
  864.    else do
  865.       popasl ID CFGF CONTENT scanprog
  866.    end
  867.  
  868.    if qsortprog=missing then do
  869.       qsortprog='SYS:Rexxc/QuickSort'
  870.       popasl ID CFGQ CONTENT qsortprog
  871.       goodconfig=FALSE
  872.       signal LoadConfigEnd
  873.    end
  874.    else do
  875.       popasl ID CFGQ CONTENT qsortprog
  876.    end
  877.    do i=1 to config.0
  878.       if i> 18 then do
  879.          infomsg='Too Many Button Entries in 'configfile
  880.          Call InfoMsg 
  881.          goodconfig=FALSE
  882.          signal LoadConfigEnd
  883.       end
  884.       j=i-1
  885.       liststr=config.i||comma||config.i.1||comma||config.i.1.1
  886.       list ID CLST POS j STRING liststr         
  887.       bname=config.i
  888.       if bname='empty' then bname='' 
  889.       bnum='B'||right(i,2,'0')
  890.       button ID bnum LABEL bname
  891.    end 
  892.  
  893.    list ID CLST POS MUIV_List_Insert_Top
  894.    liststr=result
  895.    list ID CLST POS MUIV_List_Insert_Top STRING liststr
  896.  
  897. LoadConfigEnd:
  898.  
  899. Return
  900.  
  901. /******************************************************************************/
  902. /*                      Edit Config Options                                   */
  903. /*                                                                            */
  904. /* Handle changing of ARexx command buttons, mail directory, flashfind, and   */
  905. /* qsort locations. Process SAVE,USE,RELOAD,CLEAR and a single level of UNDO. */
  906. /*                                                                            */
  907. /******************************************************************************/
  908. ConfigEdit:
  909.  
  910.    if debug then say 'entered ConfigEdit'
  911.    if debug then say 'parm='parm
  912.  
  913.    list ID CLST MUIA_List_Active
  914.    cpos=result
  915.    if debug then say 'cpos='cpos
  916.  
  917.    string ID CFG1
  918.    cfgS1=result
  919.    
  920.    cycle ID CFG2
  921.    cfgS2=result
  922.  
  923.    popasl ID CFG3
  924.    cfgS3=result
  925.  
  926.    select
  927.       when parm='UPDATE' then do
  928.         liststr=cfgS1||comma||cfgS2||comma||cfgS3
  929.         list ID CLST POS cpos STRING liststr
  930.       end 
  931.       when parm='EDIT' then do
  932.          parse var rest oldcfgS1 ',' oldcfgS2 ',' oldcfgS3
  933.          oldcfgS1=strip(oldcfgS1)
  934.          oldcfgS2=strip(oldcfgS2)
  935.          oldcfgS3=strip(oldcfgS3)
  936.          liststr='"'||oldcfgS1||comma||oldcfgS2||comma||oldcfgs3||'"'
  937.          setvar ytoldcfg liststr
  938.          if substr(oldcfgS1,1,5)='empty' then oldcfgs1=''
  939.          string ID CFG1 CONTENT oldcfgS1 
  940.          if oldcfgS2='none' then oldcfgs2=''
  941.          cycle ID CFG2 LABELS oldcfgS2 
  942.          if pos('--available--',oldcfgS3)>0 then oldcfgS3='YAM:rexx'
  943.          popasl ID CFG3 CONTENT oldcfgS3
  944.       end
  945.       when parm='CLEAR' then do
  946.         list ID CLST POS cpos STRING emptyconfig
  947.       end 
  948.       when parm='USE' then do
  949.            Call ValidateConfig
  950.            Call UpdateButtons
  951.            Call EnsureLibs
  952.       end 
  953.       when parm='SAVE' then do
  954.            Call ValidateConfig
  955.            Call UpdateButtons
  956.            Call SaveConfig
  957.            Call EnsureLibs
  958.       end 
  959.       when parm='SAVEAS' then do
  960.            Call AskConfig
  961.            Call ValidateConfig
  962.            Call UpdateButtons
  963.            Call SaveConfig
  964.            Call EnsureLibs
  965.       end 
  966.       when parm='RELOAD' then do
  967.            getvar YAMTOOLSCONFIG 
  968.            parm=result   
  969.            Call LoadConfig
  970.            Call ValidateConfig
  971.            Call EnsureLibs
  972.       end 
  973.       when parm='READ' then do
  974.            Call AskConfig
  975.            getvar YAMTOOLSCONFIG 
  976.            parm=result   
  977.            Call LoadConfig
  978.            Call ValidateConfig
  979.            Call EnsureLibs
  980.       end 
  981.       when parm='UNDO' then do
  982.          getvar ytoldcfg
  983.          oldcfg=result
  984.          parse var oldcfg oldcfgS1 ',' oldcfgS2 ',' oldcfgS3
  985.          liststr=oldcfgS1||comma||oldcfgS2||comma||oldcfgS3
  986.          list ID CLST POS cpos STRING liststr
  987.       end 
  988.       otherwise do
  989.          if debug then say 'otherwise in CONFIGEDIT'
  990.       end
  991.    end  
  992.  
  993. Return
  994.  
  995. /******************************************************************************/
  996. /*                                                                            */
  997. /* Ask user for name of configuration file to either READ or SAVEAS           */
  998. /*                                                                            */
  999. /******************************************************************************/
  1000. AskConfig:   
  1001.  
  1002.    getvar YAMTOOLSCONFIG 
  1003.    configfile=result   
  1004.    setvar OLDYTCONFIG configfile
  1005.  
  1006.    select
  1007.       when lastpos('/',configfile)>0 then do
  1008.          figfile=substr(configfile,lastpos('/',configfile)+1)
  1009.          figdir=substr(configfile,1,lastpos('/',configfile)-1)
  1010.       end
  1011.       when lastpos(':',configfile)>0 then do
  1012.          figfile=substr(configfile,lastpos(':',configfile)+1)
  1013.          figdir=substr(configfile,1,lastpos(':',configfile)-1)
  1014.       end
  1015.       otherwise do
  1016.          figfile='YamTools.config'
  1017.          figdir='YAM:rexx'
  1018.       end
  1019.    end
  1020.  
  1021.    aslrequest ID YTWIN TITLE '"Select File"',
  1022.               ATTRS ASLFR_InitialDrawer figdir ASLFR_InitialFile figfile 
  1023.    if rc = 0 then do
  1024.       configfile=result
  1025.       setvar YAMTOOLSCONFIG configfile
  1026.       if debug then say 'Configfile from ASLFR='configfile
  1027.    end
  1028.  
  1029.  
  1030. Return
  1031.  
  1032. /******************************************************************************/
  1033. /*                                                                            */
  1034. /* SAVE configuration file to file pointed at by the MuiRexx YAMTOOLSCONFIG   */
  1035. /* variable. Very simple format for config file.                              */
  1036. /*                                                                            */
  1037. /******************************************************************************/
  1038. SaveConfig:   
  1039.  
  1040.    list ID CLST MUIA_List_Active
  1041.    cpos=result
  1042.  
  1043.    getvar YAMTOOLSCONFIG 
  1044.    configfile=result   
  1045.  
  1046.    goodopen=open('OUT',configfile,'W')
  1047.    if goodopen then do 
  1048.       foo=writeln('OUT',configheader)
  1049.       popasl ID CFGM
  1050.       maildir=result
  1051.       text   ID MDIR LABEL   maildir
  1052.       liststr='MAILDIR'||' '||maildir
  1053.       foo=writeln('OUT',liststr)       
  1054.       popasl ID CFGF 
  1055.       scanprog=result
  1056.       liststr='SCANPROG'||' '||scanprog
  1057.       foo=writeln('OUT',liststr)       
  1058.       popasl ID CFGQ
  1059.       qsortprog=result
  1060.       liststr='QSORTPROG'||' '||qsortprog
  1061.       foo=writeln('OUT',liststr)       
  1062.       do i=0 to 17
  1063.          j=i+1
  1064.          list ID CLST POS i
  1065.          oldcfg=result
  1066.          parse var oldcfg oldcfgS1 ',' oldcfgS2 ',' oldcfgS3
  1067.          liststr=oldcfgS1||comma||oldcfgS2||comma||oldcfgS3
  1068.          foo=writeln('OUT',liststr)
  1069.       end
  1070.       result=close('OUT')
  1071.    end
  1072.    else do
  1073.       errmsg='Unable to open Config file for output'
  1074.       Call ErrorMsg 
  1075.    end
  1076.  
  1077.    list ID CLST POS cpos
  1078.  
  1079. Return
  1080.  
  1081. /******************************************************************************/
  1082. /*                                                                            */
  1083. /* Validate ALL of the Configuration information.                             */
  1084. /*                                                                            */
  1085. /******************************************************************************/
  1086. ValidateConfig:
  1087.  
  1088.    popasl ID CFGM
  1089.    maildir=result
  1090.    if ~exists(maildir) then do
  1091.       goodconfig=FALSE
  1092.       errmsg='"Mail directory: "'||maildir||" does not exist"
  1093.       Call Errormsg
  1094.    end
  1095.    text   ID MDIR LABEL   maildir
  1096.  
  1097.    popasl ID CFGF 
  1098.    scanprog=result
  1099.    if ~exists(scanprog) then do
  1100.       goodconfig=FALSE
  1101.       errmsg='"Scan program: "'||scanprog||" does not exist"
  1102.       Call Errormsg
  1103.    end
  1104.    
  1105.    popasl ID CFGQ
  1106.    qsortprog=result
  1107.    if ~exists(qsortprog) then do
  1108.       goodconfig=FALSE
  1109.       errmsg='"QuickSort program: "'||qsortprog||" does not exist"
  1110.       Call Errormsg
  1111.    end
  1112.  
  1113.    do i=0 to 17
  1114.       list ID CLST POS i
  1115.       oldcfg=result
  1116.       parse var oldcfg blabel ',' ptype ',' rexxprog
  1117.       if blabel='empty' then iterate
  1118.       if ~exists(rexxprog) then do
  1119.          goodconfig=FALSE
  1120.          errmsg='"ARexx program: "'||rexxprog||" does not exist"
  1121.          Call Errormsg
  1122.       end
  1123.       if blabel='' then do
  1124.          goodconfig=FALSE
  1125.          errmsg='"Label is required for: "'||rexxprog
  1126.          Call Errormsg
  1127.       end
  1128.    end
  1129.  
  1130. Return
  1131.  
  1132. /******************************************************************************/
  1133. /*                                                                            */
  1134. /* Update the labels on the ARexx command buttons to match the current config.*/
  1135. /*                                                                            */
  1136. /******************************************************************************/
  1137. UpdateButtons:
  1138.  
  1139.    list ID CLST MUIA_List_Active
  1140.    cpos=result
  1141.  
  1142.    do i=0 to 17
  1143.       j=i+1
  1144.       list ID CLST POS i
  1145.       liststr=result
  1146.       parse var liststr blabel ',' rest
  1147.       if blabel='empty' then blabel=''
  1148.       bid='B'||right(j,2,'0')
  1149.       button ID bid LABEL blabel
  1150.    end
  1151.  
  1152.    list ID CLST POS cpos
  1153.  
  1154. Return
  1155.  
  1156. /******************************************************************************/
  1157. /*                                                                            */
  1158. /* Load the Folder List on page 1 of the YAMTOOLS window.                     */
  1159. /*                                                                            */
  1160. /******************************************************************************/
  1161. LoadArchList:
  1162.  
  1163.    do i=1 to finfo.0
  1164.       liststr=finfo.i.1||comma||finfo.i.1.1.1||comma||finfo.i.1.1||comma||i-1
  1165.       list ID ALST INSERT POS MUIV_List_Insert_Bottom STRING liststr
  1166.    end
  1167.  
  1168. Return
  1169.  
  1170. /******************************************************************************/
  1171. /*                                                                            */
  1172. /* Clear all entries in the Folder List.                                      */
  1173. /*                                                                            */
  1174. /******************************************************************************/
  1175. ClrArchList:
  1176.  
  1177.    list ID ALST ATTRS MUIA_List_Entries
  1178.    acnt=result
  1179.  
  1180.    do i=1 to acnt
  1181.       list ID ALST POS MUIV_List_Insert_Top STRING
  1182.    end
  1183.  
  1184. Return
  1185.  
  1186. /******************************************************************************/
  1187. /*                                                                            */
  1188. /* Uncheck ALL if ANY of the others are set to ON. Unset others if user turns */
  1189. /* on the ALL lines option.                                                   */
  1190. /*                                                                            */
  1191. /******************************************************************************/
  1192. SetAllCheck:
  1193.  
  1194.    check ID parm
  1195.    status=result
  1196.    if status then do
  1197.       Select
  1198.          when parm='SRCA' then do
  1199.             check ID SRCS ATTRS MUIA_Selected FALSE
  1200.             check ID SRCF ATTRS MUIA_Selected FALSE
  1201.             check ID SRCT ATTRS MUIA_Selected FALSE
  1202.             check ID SRCM ATTRS MUIA_Selected FALSE
  1203.          end
  1204.          otherwise do
  1205.             check ID SRCA ATTRS MUIA_Selected FALSE
  1206.          end 
  1207.       end 
  1208.    end
  1209.  
  1210. Return
  1211.  
  1212. /******************************************************************************/
  1213. /*  Create mail list of all mail in folder.                                   */
  1214. /******************************************************************************/
  1215. ListMail:
  1216.    
  1217.    if debug then say 'Entered ListMail:'
  1218.    aline=parm||rest
  1219.    if debug then say aline
  1220.    parse var aline arch ',' size ',' afile ',' anum ',' rest
  1221.    if debug then say '  arch='arch 
  1222.    if debug then say '  size='size
  1223.    if debug then say '  anum='anum 
  1224.    if debug then say '  afile='afile
  1225.    Address YAM "setfolder" anum
  1226.  
  1227.    list ID MLST ATTRS MUIA_List_Entries
  1228.    mcnt=result
  1229.    if debug then say 'mcnt='mcnt
  1230.  
  1231.    if debug then say 'Clearing Mail List '
  1232.    
  1233.    infotitle='"YAM Tools Search"'
  1234.    infotext="Loading Mail list..."
  1235.    infobuttons='"Continue,Interrupt,Abort"'
  1236.    showbusy=TRUE
  1237.  
  1238.    Call InfoWindow
  1239.  
  1240.    do i=1 to mcnt
  1241.       list ID MLST POS MUIV_List_Insert_Top STRING
  1242.    end
  1243.  
  1244.    do i=0 to size-1
  1245.       mnum=i
  1246.       Address YAM "setmail" mnum
  1247.       Address YAM "getmailinfo file"
  1248.       mpath=result
  1249.       file=substr(mpath,lastpos('/',mpath)+1)   /* just the filename part*/
  1250.       Address YAM "getmailinfo from"
  1251.       from=result
  1252.       if pos('<',from)>1 then from=substr(from,1,pos('<',from)-1)
  1253.       from=translate(from,' ',',')
  1254.       Address YAM "getmailinfo subject"
  1255.       subj=result
  1256.       subj=translate(subj,' ',',') 
  1257.       Address YAM "getmailinfo to"
  1258.       mfor=result
  1259.       mfor=translate(mfor,' ',',')
  1260.       liststr=arch||comma||from||comma||subj||comma||mfor||comma||mnum||comma||anum||comma||file
  1261.       if debug then say liststr
  1262.       list ID MLST INSERT POS MUIV_List_Insert_Bottom STRING liststr
  1263.       radio ID SQUIT 
  1264.       squitopt=result
  1265.       select
  1266.          when squitopt="Interrupt" then leave i
  1267.          when squitopt="Abort" then do
  1268.             signal ListMailEnd
  1269.          end
  1270.          otherwise nop
  1271.       end
  1272.    end
  1273.  
  1274.    group ID YTPGS LABELS '"Mail List"'
  1275.  
  1276. ListMailEnd:
  1277.  
  1278.    window ID YTINF CLOSE   
  1279.  
  1280. Return
  1281. /******************************************************************************/
  1282. /*  Read mail the user selected.                                              */
  1283. /******************************************************************************/
  1284. ReadMail:
  1285.    
  1286.    if debug then say 'Entered ReadMail:'
  1287.    mline=parm||rest
  1288.    if debug then say mline
  1289.    parse var mline arch ',' from ',' subject ',' mfor ','mnum ',' anum ',' file
  1290.    Address YAM "setfolder" anum
  1291.    Address YAM "setmail" mnum
  1292.    Address YAM "getmailinfo file"
  1293.    mpath=result
  1294.    if debug then say 'mpath='mpath
  1295.    if debug then say 'file='file
  1296.    if pos(file,mpath)=0 then do
  1297.       infotext='Order of mail in folder has changed\nSearching for mail...'
  1298.       showbusy=TRUE
  1299.       infobuttons=""
  1300.       Call InfoWindow
  1301.       Address YAM "getfolderinfo max"
  1302.       mcnt=result
  1303.       do i=0 to mcnt-1
  1304.          Address YAM "setmail" i
  1305.          Address YAM "getmailinfo file"
  1306.          mpath=result
  1307.          if pos(file,mpath)~=0 then do
  1308.             window ID YTINF CLOSE
  1309.             leave i
  1310.          end
  1311.          else mpath=missing
  1312.       end
  1313.    end
  1314.  
  1315.    if mpath~=missing then do
  1316.       Address Command "sys:Utilities/multiview " mpath "PUBSCREEN="screen
  1317.       /*   Address YAM "mailreply"     */
  1318.    end
  1319.    else do
  1320.       window ID YTINF CLOSE
  1321.       errmsg="This mail has been moved or deleted"
  1322.       Call ErrorMsg
  1323.    end
  1324.  
  1325. Return
  1326.  
  1327. /******************************************************************************/
  1328. /*                                                                            */
  1329. /* Determine loop control and then invoke the specified command for each of   */
  1330. /* folders, directories, mail, or filenames as appropriate.                   */
  1331. /*                                                                            */
  1332. /******************************************************************************/
  1333. DoRexxButton:
  1334.  
  1335.    butid='B'||parm 
  1336.    list ID CLST POS parm-1
  1337.    cmdline=result
  1338.    if debug then say 'Entered DoRexxButton'
  1339.    if debug then say 'cmdline='cmdline
  1340.  
  1341.    parse var cmdline blabel ',' btype ',' bcommand
  1342.         
  1343.    group ID YTPGS REGISTER
  1344.    pagename=result
  1345.  
  1346.    select 
  1347.       when pagename='Mail List' then do
  1348.          if upper(btype)='FOLDER' then do
  1349.             errmsg='This command needs to be run from the folder list'
  1350.             signal ErrorMsg
  1351.          end                
  1352.          else do
  1353.             list ID MLST ATTRS MUIA_List_Entries
  1354.             mcnt=result
  1355.             if debug then say 'mcnt='mcnt
  1356.             infotext="\n\n      Starting to process entries      \n\n"
  1357.             showbusy=TRUE
  1358.             infobuttons='"Continue,Abort"'
  1359.             Call InfoWindow
  1360.             do msel=0 to mcnt
  1361.                list ID MLST
  1362.                mline=result
  1363.                if mline='' then leave msel
  1364.                parse var mline arch ',' from ',' subj ',' mfor ',' mnum ',' anum ',' file
  1365.                if debug then say 'mline='mline
  1366.                Address YAM "setfolder" anum
  1367.                Address YAM "setmail" mnum
  1368.                Address YAM "getmailinfo file"
  1369.                mpath=result
  1370.                infotext="Processing Folder "||arch||"\nMail entry "||mnum+1
  1371.                 text ID STEXT LABEL infotext
  1372.                if pos(file,mpath)=0 then do
  1373.                   infotext="Order of mail in folder has changed\nSearching for mail..."
  1374.                     text ID STEXT LABEL infotext
  1375.                   Address YAM "getfolderinfo max"
  1376.                   xmcnt=result
  1377.                   do i=0 to xmcnt-1
  1378.                      Address YAM "setmail" i
  1379.                      Address YAM "getmailinfo file"
  1380.                      mpath=result
  1381.                      if pos(file,mpath)~=0 then do
  1382.                         leave i
  1383.                      end
  1384.                      else mpath=missing
  1385.                   end
  1386.                end
  1387.                if mpath~=missing then do
  1388.                   intcommand="Call '"bcommand"' '"mpath"'"
  1389.                   if debug then say 'intcommand='intcommand
  1390.                   interpret intcommand
  1391.                end
  1392.                else do
  1393.                   infotext="Mail has been deleted or moved\nContinuing with others"
  1394.                     text ID STEXT LABEL infotext
  1395.                end
  1396.                radio ID SQUIT 
  1397.                squitopt=result
  1398.                if squitopt="Abort" then leave msel
  1399.             end
  1400.             window ID YTINF CLOSE
  1401.          end
  1402.       end
  1403.       when pagename='Folder List' then do
  1404.          list ID ALST ATTRS MUIA_List_Entries
  1405.          acnt=result
  1406.          infotext="\n\n      Starting to process entries      \n\n"
  1407.          showbusy=TRUE
  1408.          infobuttons='"Continue,Abort"'
  1409.          Call InfoWindow
  1410.          do asel=0 to acnt
  1411.             list ID ALST
  1412.             aline=result
  1413.             if aline='' then leave asel
  1414.             parse var aline arch ',' size ',' file ',' anum ',' rest
  1415.             if debug then say 'aline='aline
  1416.                 if size=0 then iterate asel
  1417.             Address YAM "setfolder" anum
  1418.             if upper(btype)='FOLDER' then do
  1419.                Address YAM "setmail 0"
  1420.                infotext="Processing Folder "||arch
  1421.                 text ID STEXT LABEL infotext
  1422.                intcommand="Call '"bcommand"' '"file"'"
  1423.                if debug then say 'intcommand='intcommand
  1424.                interpret intcommand
  1425.                radio ID SQUIT 
  1426.                squitopt=result
  1427.                if squitopt="Abort" then leave asel
  1428.             end
  1429.             else do
  1430.                Address YAM "getfolderinfo max"
  1431.                mcnt=result
  1432.                do mnum=0 to mcnt-1
  1433.                   Address YAM "setmail" mnum
  1434.                   Address YAM "getmailinfo file"
  1435.                   mpath=result
  1436.                    infotext="Processing Folder "||arch||"\nMail entry "||mnum+1||"/"||mcnt
  1437.                     text ID STEXT LABEL infotext
  1438.                   intcommand="Call '"bcommand"' '"mpath"'"
  1439.                   if debug then say 'intcommand='intcommand
  1440.                   interpret intcommand
  1441.                   radio ID SQUIT 
  1442.                   squitopt=result
  1443.                   if squitopt="Abort" then leave asel
  1444.                end
  1445.             end
  1446.          end
  1447.          window ID YTINF CLOSE
  1448.       end
  1449.       when pagename='Config' then do
  1450.          errmsg='Cannot Execute Buttons from Config Window'
  1451.          Call ErrorMsg
  1452.       end
  1453.       otherwise do
  1454.          infomsg= 'Found otherwise in DoRexxButton'
  1455.          Call InfoMsg
  1456.       end
  1457.    end       
  1458.  
  1459. Return
  1460.  
  1461. /******************************************************************************/
  1462. /*   Get information from main search screen, scan files for search strings   */
  1463. /*   Build screen list of mail that matches criteria                          */
  1464. /******************************************************************************/
  1465. SearchArchs:
  1466.  
  1467.    ADDRESS YAMTOOLS
  1468.  
  1469.    popasl ID CFGM
  1470.    maildir=result
  1471.  
  1472.    popasl ID CFGF 
  1473.    scanprog=result
  1474.  
  1475.    popasl ID CFGQ
  1476.    qsortprog=result
  1477.  
  1478.     tmpfile="T:ytsearch."||timestamp
  1479.    timerfile="T:ytwait."||timestamp
  1480.  
  1481.     sptr=0 
  1482.    srchstr.=missing
  1483.    srchstr.0=0
  1484.  
  1485.    Archlist.=missing
  1486.    Archlist.0=0
  1487.  
  1488.    Matches.=missing
  1489.    Matches.0=0
  1490.  
  1491.    string ID SRC1
  1492.    sval=result
  1493.     if sval~='' & sval~='RESULT' then do
  1494.        srchstr.0=1+srchstr.0
  1495.        sptr=srchstr.0
  1496.       srchstr.sptr=sval
  1497.       srchstr.sptr.1=0
  1498.       if debug then say srchstr.0 'search string:' srchstr.sptr
  1499.    end
  1500.    
  1501.    string ID SRC2
  1502.    sval=result
  1503.    if sval~='' & sval~='RESULT' then do
  1504.       srchstr.0=1+srchstr.0
  1505.       sptr=srchstr.0
  1506.       srchstr.sptr=sval
  1507.       srchstr.sptr.1=0
  1508.       if debug then say srchstr.0 'search string:' srchstr.sptr
  1509.    end
  1510.    
  1511.    string ID SRC3
  1512.    sval=result
  1513.    if sval~='' & sval~='RESULT' then do
  1514.       srchstr.0=1+srchstr.0
  1515.       sptr=srchstr.0
  1516.        srchstr.sptr=sval
  1517.       srchstr.sptr.1=0
  1518.       if debug then say srchstr.0 'search string:' srchstr.sptr
  1519.     end
  1520.  
  1521.    if sptr=0 then do
  1522.       errmsg="Specify SEARCH strings"
  1523.       Call ErrorMsg
  1524.    end
  1525.  
  1526.    check ID SRCS
  1527.    srchsubj=result
  1528.    check ID SRCF
  1529.    srchfrom=result
  1530.    check ID SRCT
  1531.    srchto=result
  1532.    check ID SRCM
  1533.    srchmsg=result
  1534.    check ID SRCA
  1535.    srchall=result
  1536.    radio ID SLOG
  1537.    matchlogic=result
  1538.    
  1539.     if matchlogic='Match Any' then matchreqs=1
  1540.                               else matchreqs=srchstr.0 
  1541.     
  1542.    list ID ALST ATTRS MUIA_List_Entries
  1543.    acnt=result
  1544.    if debug then say 'acnt='acnt
  1545.    
  1546.    list ID MLST ATTRS MUIA_List_Entries
  1547.    mcnt=result
  1548.    if debug then say 'mcnt='mcnt
  1549.  
  1550.    if debug then say 'Clearing Mail List '
  1551.    
  1552.    do i=1 to mcnt
  1553.       list ID MLST POS MUIV_List_Insert_Top STRING
  1554.    end
  1555.  
  1556.    button ID SRCX PORT YAMTOOLS ATTRS MUIA_Disabled TRUE
  1557.  
  1558.    infotitle='"YAM Tools Search"'
  1559.    infotext="Starting to Search Folders"
  1560.    infobuttons='"Continue,Interrupt,Abort"'
  1561.    showbusy=TRUE
  1562.  
  1563.    Call InfoWindow
  1564.  
  1565.    do asel=0 to acnt
  1566.       list ID ALST
  1567.       aline=result
  1568.       if aline='' then break
  1569.       parse var aline arch ',' size ',' file ',' anum ',' rest
  1570.       text ID STEXT LABEL "Scanning: "arch
  1571.       if debug then say 'Call SearchArchive for:' aline
  1572.       if size > 0 then Call SearchArchive
  1573.       archcnt=asel+1 
  1574.       Archlist.0=archcnt
  1575.       Archlist.archcnt=arch
  1576.       Archlist.archcnt.1=anum
  1577.       Archlist.archcnt.1.1=file
  1578.       radio ID SQUIT 
  1579.       squitopt=result
  1580.       select
  1581.          when squitopt="Interrupt" then leave asel
  1582.          when squitopt="Abort" then do
  1583.             signal SearchArchsEnd
  1584.          end
  1585.          otherwise nop
  1586.       end
  1587.    end
  1588.  
  1589.    if exists(timerfile) then do
  1590.       if ~debug then do
  1591.          Address Command 'Delete ' timerfile 'Quiet'
  1592.       end
  1593.    end   
  1594.  
  1595.    if asel=0 then do
  1596.       errmsg="Select Folders to Search"
  1597.       Call ReEnableSearch
  1598.       Call ErrorMsg
  1599.    end
  1600.  
  1601.    Call DoScanFile
  1602.  
  1603.    radio ID SQUIT 
  1604.    if result~="Continue" then do
  1605.       Call ReEnableSearch
  1606.       errmsg="Search Interrupted/Aborted"
  1607.       Call ErrorMsg
  1608.    end
  1609.  
  1610.    list ID MLST INSERT POS MUIV_List_Insert_Bottom ATTRS MUIA_List_Quiet TRUE
  1611.  
  1612.    if debug then say 'starting match archlist to matches'
  1613.    if Matches.0=0 then do
  1614.       errmsg="No Matches Found"
  1615.       Call ReEnableSearch
  1616.       Call ErrorMsg
  1617.    end
  1618.    do i=1 to Archlist.0
  1619.       do j=1 to Matches.0
  1620.          if upper(Matches.j.1)=upper(Archlist.i.1.1) then do
  1621.             Matches.j=Archlist.i
  1622.             Matches.j.1.1.1=Archlist.i.1
  1623.          end
  1624.       end
  1625.    end
  1626.  
  1627. /**************************************************************************/
  1628. /*            Match of scan results to mail within each folder            */
  1629. /*                                                                        */
  1630. /* If only 1 match is found in a given folder then we just loop thru the  */
  1631. /* mail until we find the matching filename. If there is more than 1 in   */
  1632. /* a specific folder then we loop thru the folder, build an array of info */
  1633. /* and then do our matching against the array. This speeds the process up */
  1634. /* for both conditions.  Remove commas from From:,To:, and Subject:       */
  1635. /**************************************************************************/
  1636.  
  1637.    if debug then say "Doing getmailinfo for i=1 to " Matches.0
  1638.    do i=1 to Matches.0
  1639.       fptr=i+1
  1640.       if matches.fptr.1.1.1=missing & i>1 then leave i
  1641.       if debug then say 'i='i 'matches.0='matches.0
  1642.       radio ID SQUIT 
  1643.       if result~="Continue" then leave i
  1644.       Address YAM "setfolder" matches.i.1.1.1
  1645.       Address YAM "getfolderinfo max"
  1646.       mailcnt=result
  1647.       if debug then say 'current/next folders' matches.i.1.1.1 matches.fptr.1.1.1
  1648.       if matches.fptr.1.1.1~=matches.i.1.1.1 then do
  1649.          do j=0 to mailcnt-1
  1650.             Address YAM "setmail" j
  1651.             Address YAM "getmailinfo file"
  1652.             mpath=result         
  1653.             if pos(matches.i.1.1,mpath)>0 then do
  1654.                matches.i.1.1.1.1=j                              /* number */
  1655.                Address YAM "getmailinfo from"
  1656.                from=result
  1657.                if pos('<',from)>1 then from=substr(from,1,pos('<',from)-1)
  1658.                matches.i.1.1.1.1.1=translate(from,' ',',')      /*from    */
  1659.                Address YAM "getmailinfo subject"
  1660.                subject=result
  1661.                matches.i.1.1.1.1.1.1=translate(subject,' ',',') /*subject */
  1662.                Address YAM "getmailinfo to"
  1663.                to=result
  1664.                matches.i.1.1.1.1.1.1.1=translate(to,' ',',')    /* To:    */
  1665.                iterate i
  1666.             end
  1667.          end
  1668.       end
  1669.       else do
  1670.          oldptr=i
  1671.          oldfolder=matches.i.1.1.1
  1672.          tempmail.=missing
  1673.          tempmail.0=0
  1674.          if debug then say 'oldptr='oldptr 'oldfolder=oldfolder'
  1675.          do j=0 to mailcnt-1
  1676.             k=j+1
  1677.             tempmail.0=k
  1678.             Address YAM "setmail" j
  1679.             Address YAM "getmailinfo file"
  1680.             tempmail.k=result
  1681.          end 
  1682.          do newptr=oldptr to matches.0
  1683.             i=newptr-1
  1684.             if debug then say 'i='i 'newptr='newptr 'current='matches.newptr.1.1.1 'oldfolder='oldfolder
  1685.             if matches.newptr.1.1.1~=oldfolder then iterate i
  1686.             do j=1 to tempmail.0
  1687.                if pos(matches.newptr.1.1,tempmail.j)>0 then do   
  1688.                   matches.newptr.1.1.1.1=j-1                    /* number */
  1689.                   Address YAM "setmail" j-1
  1690.                   Address YAM "getmailinfo from"
  1691.                   from=result
  1692.                   if pos('<',from)>1 then from=substr(from,1,pos('<',from)-1)
  1693.                   matches.newptr.1.1.1.1.1=translate(from,' ',',')
  1694.                   Address YAM "getmailinfo subject"
  1695.                   subject=result
  1696.                   matches.newptr.1.1.1.1.1.1=translate(subject,' ',',') 
  1697.                   Address YAM "getmailinfo to"
  1698.                   to=result
  1699.                   matches.newptr.1.1.1.1.1.1.1=translate(to,' ',',')
  1700.                   iterate newptr
  1701.                end
  1702.             end
  1703.          end
  1704.       end
  1705.    end
  1706.  
  1707. /**************************************************************************/
  1708. /*   Build the Mail List and switch to the Mail List page.                */
  1709. /**************************************************************************/
  1710.  
  1711.    if debug then say 'Placing info in MLST'
  1712.     do i=1 to Matches.0
  1713.       arch=Matches.i
  1714.       path=Matches.i.1
  1715.       file=Matches.i.1.1
  1716.       anum=Matches.i.1.1.1
  1717.       mnum=Matches.i.1.1.1.1
  1718.       from=Matches.i.1.1.1.1.1
  1719.       subj=Matches.i.1.1.1.1.1.1      
  1720.       mfor=Matches.i.1.1.1.1.1.1.1      
  1721.       liststr=arch||comma||from||comma||subj||comma||mfor||comma||mnum||comma||anum||comma||file
  1722.       list ID MLST INSERT POS MUIV_List_Insert_Bottom STRING liststr
  1723.         if debug then say 'match file='file
  1724.         if debug then say 'match path='path
  1725.    end
  1726.    list ID MLST ATTRS MUIA_List_Quiet FALSE
  1727.  
  1728.    group ID YTPGS LABELS '"Mail List"'
  1729.  
  1730.    
  1731.  
  1732. SearchArchsEnd:
  1733. ReEnableSearch:
  1734.  
  1735.    window ID YTINF CLOSE   
  1736.  
  1737.    button ID SRCX HELP help.SRCX  NODE node.SRCX COMMAND '"YamTools.rexx SEARCH "', 
  1738.           PRESS ATTRS MUIA_CycleChain TRUE MUIA_Disabled FALSE,
  1739.           LABEL 'Search'
  1740.  
  1741. Return
  1742.  
  1743. /******************************************************************************/
  1744. /*                                                                            */
  1745. /******************************************************************************/
  1746. SearchArchive:
  1747.  
  1748.     sfile=file||'/'
  1749.       
  1750.    do j=1 to srchstr.0
  1751.       if debug then say 'starting 'scanprog sfile srchstr.j
  1752.       Address Command "run >nil: "scanprog sfile '"'srchstr.j'"' " NH NUM >>"tmpfile
  1753.       Call WaitScanDone
  1754.       if debug then say 'finished 'scanprog sfile srchstr.j
  1755.       radio ID SQUIT 
  1756.       if result~="Continue" then leave j     
  1757.    end
  1758.  
  1759. Return
  1760.    
  1761. /**************************************************************************/
  1762. /*                                                                        */
  1763. /* Scan files with output to a temp file. Read lines back into array.     */
  1764. /* Sort the array. Sorted array becomes input for further processing.     */
  1765. /*                                                                        */
  1766. /**************************************************************************/
  1767. DoScanFile:
  1768.  
  1769.    infotext="Building Match List..."
  1770.    text ID STEXT LABEL infotext
  1771.  
  1772.    ScanArray.=missing          /* stores parsed information from scan prg */
  1773.    ScanArray.0=0                            /* no scan lines yet          */
  1774.    sptr=0                                   /* counter for array          */     
  1775.  
  1776.    Matches.=missing                         /* array for matches          */
  1777.    Matches.0=0                              /* none yet                   */
  1778.    matchcnt=0                               /* used to determine matches  */
  1779.  
  1780.    olddir =missing                          /* level break controls       */
  1781.    oldfile=missing                          /* level break controls       */
  1782.  
  1783.    goodopen=open('IN',tmpfile,'R')
  1784.    if ~goodopen then do
  1785.       /* put user notification code/call here */
  1786.       exit
  1787.    end
  1788.  
  1789.    do until eof('IN')
  1790.       linein=readln('IN')
  1791.       select
  1792.          when words(linein)=2 & word(linein,2)='...' then do
  1793.             fullname=word(linein,1)              /* filename with path    */
  1794.             chop=lastpos('/',fullname)           /* start of filename     */
  1795.             filename=substr(fullname,chop+1)     /* just the filename part*/
  1796.             dirname=substr(fullname,1,chop-1)    /* path info             */
  1797.          end
  1798.          when words(linein) > 0 then do
  1799.             linenum=strip(word(linein,1))        /* line number found     */
  1800.             linenum=right(linenum,6,'0')         /* put in leading zeros  */
  1801.             text=subword(linein,2)               /* remaining string      */
  1802.             sptr=sptr+1                          /* increment cnter       */
  1803.             scanarray.0=sptr                     /* store it              */    
  1804.             scanarray.sptr=dirname filename linenum text /* store it      */
  1805.          end
  1806.          otherwise nop                           /* should be end of file */
  1807.       end
  1808.    end
  1809.  
  1810.    result=close('IN')                            /* close the scan file   */
  1811.  
  1812.    if ~debug then do
  1813.       Address Command 'Delete ' tmpfile 'quiet'  /* delete it             */
  1814.    end
  1815.  
  1816.    if show('L','rexxtricks.library') then do    /* use tricks library     */
  1817.       call QSORT(scanarray)                  /* sort by name, line number */
  1818.    end
  1819.    else do                                   /* use QuickSort format      */
  1820.       call QSORT(1,scanarray.0,scanarray)    /* sort by name, line number */
  1821.    end 
  1822.  
  1823.    do i=1 to scanarray.0
  1824.       dirname=word(scanarray.i,1)                /* directory in array    */
  1825.       filename=word(scanarray.i,2)               /* filename in array     */
  1826.       linenum=word(scanarray.i,3)                /* line number in array  */       
  1827.       text=subword(scanarray.i,4)                /* remainder of line     */
  1828.       if dirname~=olddir | filename~=oldfile then do
  1829.          Call TestMatch                          /* see if we use this one*/
  1830.       end
  1831.       type=word(text,1)                          /* header word ??        */
  1832.       if srchall=FALSE then do 
  1833.          Call FilterLines                        /* accept/reject lines   */      
  1834.          if skipline then iterate i
  1835.       end
  1836.       do j=1 to srchstr.0                        /* loop thru search vals */
  1837.          if pos(upper(srchstr.j),upper(text))>0 then do /* found match    */
  1838.             srchstr.j.1=1                        /* mark as found         */ 
  1839.          end
  1840.       end
  1841.    end                                  /* matches do i=1 to scanarray.0  */
  1842.  
  1843.    Call TestMatch                                /* test LAST file        */
  1844.  
  1845. Return
  1846.  
  1847. /**************************************************************************/
  1848. /*                                                                        */
  1849. /* Need to accept/reject lines based on type.                             */
  1850. /* Easy ones are Subject: From: To: etc.                                  */
  1851. /* Assume that if variable type (word 1 of line) ends in ':' not text line*/
  1852. /*                                                                        */
  1853. /**************************************************************************/
  1854. FilterLines:
  1855.    
  1856.    skipline=FALSE                                /* assume good line      */
  1857.    select
  1858.        when right(type,1)~=':' & srchmsg then nop
  1859.        when right(type,1)~=':' & srchmsg then nop
  1860.       when type='Subject:' & srchsubj then nop 
  1861.       when type='From:' & srchfrom then nop 
  1862.       when type='Reply-To:' & srchfrom then nop 
  1863.       when type='Sender:' & srchfrom then nop 
  1864.       when type='To:' & srchto then nop 
  1865.       when type='CC:' & srchto then nop 
  1866.       otherwise skipline=TRUE                    /* assume we skip it     */
  1867.    end
  1868.  
  1869. Return
  1870.  
  1871. /**************************************************************************/
  1872. /*                                                                        */
  1873. /* Test for match condition and reset the necessary variables.            */
  1874. /* for 'AND' conditions matchcnt should be the sum of how many searches   */
  1875. /* for 'OR'  any search value found counts as a match                     */
  1876. /*                                                                        */
  1877. /**************************************************************************/
  1878. TestMatch:
  1879.  
  1880.    matchcnt=0                                    /* reset for new file    */
  1881.  
  1882.    do j=1 to srchstr.0
  1883.       matchcnt=matchcnt+srchstr.j.1              /* get match counts      */
  1884.    end
  1885.  
  1886.    if matchcnt>=matchreqs & olddir~=missing then do       /* got a match  */
  1887.       Matches.0=1+Matches.0                      /* count it              */
  1888.       mptr=matches.0
  1889.       Matches.mptr.1=olddir                      /* store directory name  */     
  1890.       Matches.mptr.1.1=oldfile                   /* store file name       */     
  1891.    end
  1892.    olddir=dirname                                /* copy for next break   */
  1893.    oldfile=filename                              /* copy for next break   */
  1894.    do j=1 to srchstr.0                           /* loop thru search vals */
  1895.       srchstr.j.1=0                              /* set matches to zero   */ 
  1896.    end
  1897.  
  1898. Return
  1899.  
  1900. /**************************************************************************/
  1901. /*              Wait until scan program not in task list                  */
  1902. /**************************************************************************/
  1903. WaitScanDone:
  1904.  
  1905.    do timer=1                                    /* allows iterate timer  */
  1906.       Address Command "status > "timerfile
  1907.       foo=delay(delaytm)                         /* pause for command     */
  1908.       goodopen=open('IN',timerfile,'R')
  1909.       if goodopen then do 
  1910.          do until eof('IN')
  1911.             linein=readln('IN')
  1912.             if pos(scanprog,linein)>0 then do
  1913.                result=close('IN')
  1914.                iterate timer                     /* keep looping          */
  1915.             end
  1916.          end
  1917.          result=close('IN')
  1918.          leave timer
  1919.       end
  1920.       else do 
  1921.          infomsg='Couldnt open timerfile'
  1922.          Call InfoMsg
  1923.       end
  1924.    end
  1925.  
  1926. Return
  1927. /******************************************************************************/
  1928. /*                                                                            */
  1929. /* Display informationn about YAMTOOLS, YAM, MUIREXX.                         */
  1930. /*                                                                            */
  1931. /******************************************************************************/
  1932. AboutProgs:
  1933.  
  1934.    bc='\033b\033c'
  1935.    nc='\033n\033c'
  1936.    nl='\n'
  1937.    nl2='\n\n'
  1938.    ct='\033c'
  1939.  
  1940.    Address YAM 'info title'
  1941.    yamtitle=result 
  1942.    Address YAM 'info copyright'
  1943.    yamcopy=result
  1944.    
  1945.    txt.0=23                                                                 
  1946.    txt.1="\033cYAMTOOLS"                               
  1947.    txt.2="\033cCopyright ©1997 by Dick Whiting"
  1948.    txt.3="\033n"                                                        
  1949.    txt.4="--------------------------------------------------------------------"
  1950.    txt.5="\033n"                                                        
  1951.    txt.6="=Standard Disclaimer: I wrote it, it works for me, I don't guarantee"
  1952.    txt.7="=that it will do anything productive for anyone else, etc. etc. ;-)"
  1953.    txt.8="\033n"                                                                    
  1954.    txt.9="=HOWEVER, if you DO find a use for it: I homeschool my kids and they"
  1955.    txt.10="=would love a postcard from where EVER you live."
  1956.    txt.11="\033n"
  1957.    txt.12="=Instant GEOGRAPHY lesson;)"
  1958.    txt.13="\033n"                                                                    
  1959.    txt.14="=POSTCARDS:   Dick Whiting"
  1960.    txt.15="=             28590 S. Beavercreek Rd."
  1961.    txt.16="=             Mulino, Oregon 97042"
  1962.    txt.17="=             USA"
  1963.    txt.18="\033n"                                                                    
  1964.    txt.19="--------------------------------------------------------------------"
  1965.    txt.20="\033n"                                                                    
  1966.    txt.21="\033cAddress Bug Reports or Comments to:"                  
  1967.    txt.22="\033cDick Whiting <dwhiting@europa.com>"
  1968.    txt.23="\033c25 February 1997"
  1969.  
  1970.    select
  1971.       when parm='YAM' then do
  1972.          ab.title="About "||yamtitle||" "||yamcopy
  1973.          aboutlist=FALSE
  1974.          fontsize="ATTRS MUIA_FONT MUIV_Font_Big"
  1975.          aboutmsg=bc||'!! T H A N K   Y O U   M A R C E L !!'         
  1976.          Call AboutWin
  1977.       end
  1978.       when parm='MUIREXX' then do
  1979.          ab.title="About "||parm
  1980.          aboutlist=FALSE
  1981.          aboutmsg=ct||"!! Great Product - Register It !!"
  1982.          Call AboutWin
  1983.       end
  1984.       otherwise do
  1985.          ab.title="About "||parm
  1986.          ab.desc="YamTools -- Add-on Tools For YAM"
  1987.          ab.copy="Version 1.1 Copyright ©1997 by Dick Whiting"
  1988.          ab.text1=yamtitle||' '||yamcopy
  1989.          ab.text2="MuiRexx © Russell Leighton"
  1990.          ab.text3="MUI © Stefan Stuntz"
  1991.          aboutmsg=bc||ab.desc||nl||nc||ab.copy||nl||txt.19||nl||ab.text1||nl||ab.text2||nl||ab.text3
  1992.          Call AboutWin
  1993.          do i=1 to txt.0
  1994.             list ID ABLST INSERT POS MUIV_List_Insert_Bottom STRING txt.i
  1995.          end
  1996.          list ID ABLST POS MUIV_List_Insert_Top
  1997.       end
  1998.    end
  1999.  
  2000. Return
  2001. /******************************************************************************/
  2002. /*  Display window for ABOUT programs.                                        */
  2003. /******************************************************************************/
  2004. AboutWin:
  2005.    window ID YTABT TITLE '"'ab.title'"' MUIA_Window_DepthGadget FALSE,
  2006.           MUIA_Window_DragBar FALSE MUIA_Window_PublicScreen screen
  2007.       group
  2008.          text fontsize LABEL aboutmsg
  2009.       endgroup
  2010.       if aboutlist then do
  2011.          group 
  2012.             list ID ABLST
  2013.          endgroup
  2014.       end
  2015.       group HORIZ
  2016.          group
  2017.             space HORIZ
  2018.          endgroup
  2019.          group
  2020.             button PRESS COMMAND '"window ID YTABT CLOSE"' PORT YAMTOOLS,
  2021.                    LABEL "Ok"
  2022.          endgroup
  2023.          group
  2024.             space HORIZ
  2025.          endgroup
  2026.       endgroup
  2027.    endwindow
  2028.  
  2029. Return
  2030.  
  2031. /******************************************************************************/
  2032. /*  Display ERROR message and EXIT.                                           */
  2033. /******************************************************************************/
  2034. ErrorMsg:
  2035.  
  2036.    window ID YTINF CLOSE
  2037.  
  2038.    request ID ERRM GADGETS '"OK"' errmsg
  2039.  
  2040.    if shutdown then do
  2041.       Address YAMTOOLS "QUIT"
  2042.    end
  2043.  
  2044.    if ~goodconfig then do
  2045.       group ID YTPGS LABELS 'Config'
  2046.    end
  2047.  
  2048.    exit
  2049.  
  2050. Return
  2051.  
  2052. /******************************************************************************/
  2053. /*  Display information message and RETURN                                    */
  2054. /******************************************************************************/
  2055. InfoMsg:
  2056.  
  2057.    request ID INFOM GADGETS '"OK"' infomsg
  2058.  
  2059. Return
  2060.  
  2061. /******************************************************************************/
  2062. /*  Simple information/error message window.                                  */
  2063. /******************************************************************************/
  2064. InfoWindow:
  2065.  
  2066.    window ID YTINF TITLE '"YAM Tools Info"' ATTRS MUIA_Window_PublicScreen screen,
  2067.           MUIA_Window_SizeGadget FALSE MUIA_Window_DragBar FALSE,
  2068.           MUIA_Window_DepthGadget FALSE
  2069.  
  2070.       group 
  2071.          group 
  2072.             text ID STEXT HELP help.STEXT  NODE node.STEXT LABEL infotext
  2073.          endgroup
  2074.          if showbusy then do
  2075.             group
  2076.                object CLASS '"Busy.mcc"' ATTRS MUIA_VertWeight 25
  2077.             endgroup
  2078.          end
  2079.          if infobuttons ~='' then do
  2080.             group HORIZ
  2081.                group 
  2082.                   space HORIZ 
  2083.                endgroup
  2084.                group 
  2085.                   radio ID SQUIT HELP help.SQUIT  NODE node.SQUIT LABELS infobuttons
  2086.                endgroup
  2087.                group 
  2088.                   space HORIZ 
  2089.                endgroup
  2090.             endgroup
  2091.          end
  2092.          else do
  2093.             group 
  2094.                space HORIZ 100
  2095.             endgroup
  2096.          end
  2097.       endgroup
  2098.    endwindow
  2099.  
  2100. Return
  2101.  
  2102. /******************************************************************************/
  2103. /*                          END OF ACTIVE CODE                                */
  2104. /******************************************************************************/
  2105.