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

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /*                             YTDelete                                       */
  4. /*                 Copyright ©1997 by Dick Whiting                            */
  5. /*                                                                            */
  6. /*----------------------------------------------------------------------------*/
  7. /* This script requires YAMTOOLS for it to work. If you don't have YAMTOOLS   */
  8. /* you can get it on Aminet in directory comm/mail. This script allows you    */
  9. /* to Delete all selected mail. This is only really useful from               */
  10. /* the mail list of a SEARCH. Otherwise, use YAM's normal capabilities.       */
  11. /*                                                                            */
  12. /*----------------------------------------------------------------------------*/
  13. /*                                                                            */
  14. /* Standard Disclaimer: I wrote it, it works for me, I don't guarantee        */
  15. /* that it will do anything productive for anyone else, etc. etc. ;-)         */
  16. /*                                                                            */
  17. /*HOWEVER, if you DO find a use for it: I homeschool my kids and they         */
  18. /*would love a postcard from where EVER you live.                             */
  19. /*                                                                            */
  20. /*Instant GEOGRAPHY lesson;)                                                  */
  21. /*                                                                            */
  22. /*                                                                            */
  23. /*POSTCARDS:    Dick Whiting                                                  */
  24. /*              28590 S. Beavercreek Rd.                                      */
  25. /*              Mulino, Oregon 97042                                          */
  26. /*              USA                                                           */
  27. /*                                                                            */
  28. /*----------------------------------------------------------------------------*/
  29. /*                                                                            */
  30. /*               Address Bug Reports or Comments to:                          */
  31. /*                Dick Whiting <dwhiting@europa.com>                          */
  32. /*                         15 June 1997                                       */
  33. /*                                                                            */
  34. /******************************************************************************/
  35. /*
  36. $VER: 1.1 Copyright ©1997 by Dick Whiting
  37. $AUTHOR: Dick Whiting
  38. $DESCRIPTION: Deleter for use with YAMTOOLS
  39. */
  40.  
  41. options results
  42. options failat 9999         /* keep maildelete return from showing */
  43.  
  44. /**************************************************************************/
  45. /*                         Initialize Variables                           */
  46. /**************************************************************************/
  47. Call MUIvars                                /* go define vars for MUI use */
  48. Call YTvars                                 /* various values used in YT  */
  49. Call Helpvars                               /* pointers into HELP guide   */
  50. Call Localize                               /* vars for localizing strings*/
  51. Call Builtvars                              /* built using previous values*/
  52.  
  53. Address YAMTOOLS
  54.  
  55. Call CheckYam
  56.  
  57. Call CheckMailList
  58. Call ProcessDeletes
  59.  
  60. exit
  61.  
  62. /**************************************************************************/
  63. /*                Check that there is some mail to process                */
  64. /**************************************************************************/
  65. CheckMailList:
  66.  
  67.    list ID MLST ATTRS MUIA_List_Entries
  68.    mcnt=result
  69.    if mcnt=0 then do
  70.       errmsg=_text._nomail
  71.       Call ErrorMsg
  72.    end
  73.  
  74. Return
  75.  
  76.  
  77. /**************************************************************************/
  78. /*                           Process Deletes                              */
  79. /**************************************************************************/
  80. ProcessDeletes:
  81.  
  82.  
  83.    request ID VERD GADGETS _text._ok||'|'||_text._cancel _text._delreq
  84.    if result=0 then exit
  85.  
  86.    infotitle=_title._info
  87.    infotext='\033n'||_text._delmail
  88.    infobuttons=_text._squit1||comma||_text._squit2||comma||_text._squit3
  89.    showbusy=TRUE
  90.  
  91.    Call InfoWindow
  92.    
  93.    list ID MLST ATTRS MUIA_List_Entries
  94.    mcnt=result
  95.  
  96.    Deletelist.=missing
  97.    Deletelist.0=0
  98.    Updlist.=missing
  99.    Updlist.0=0
  100.    acnt=0
  101.  
  102.    do i=0 to mcnt-1
  103.       list ID MLST
  104.       mline=result
  105.       if mline='' then break
  106.       parse var mline arch ',' from ',' subj ',' mfor ',' mnum ',' anum ',' file
  107.       acnt=acnt+1
  108.       anum=right(anum,6,'0')
  109.       mnum=right(mnum,6,'0')
  110.       Deletelist.0=acnt
  111.       Deletelist.acnt=anum mnum file subj
  112.       radio ID SQUIT 
  113.       if result~=_text._squit1 then leave
  114.    end
  115.    Updlist.0=Deletelist.0
  116.  
  117.    if acnt=0 then do
  118.       errmsg=_text._nomail
  119.       Call ErrorMsg     
  120.    end
  121.  
  122.    if show('L','rexxtricks.library') then do    /* use tricks library     */
  123.       call QSORT(Deletelist)                 /* sort by name, line number */
  124.    end
  125.    else do                                   /* use QuickSort format      */
  126.       call QSORT(1, Deletelist.0, Deletelist) /* sort by name, number     */
  127.    end 
  128.  
  129.    do i=Deletelist.0 to 1 by -1              /* process in reverse order  */
  130.       anum=word(Deletelist.i,1)
  131.       anum=strip(anum,'L','0')
  132.       if anum='' then anum=0
  133.       mnum=word(Deletelist.i,2)
  134.       mnum=strip(mnum,'L','0')
  135.       if mnum='' then mnum=0
  136.       file=word(Deletelist.i,3)
  137.       subj=subword(Deletelist.i,4)
  138.       Updlist.i=anum
  139.       Updlist.i.1=mnum
  140.       Updlist.i.1.1=file
  141.       Updlist.i.1.1.1=subj
  142.       Address YAM 'setfolder 'anum           /* goto folder               */
  143.       Address YAM 'setmail 'mnum             /* set to mail               */
  144.       Address YAM "getmailinfo file"         /* verify filename           */
  145.       xfile=result
  146.       xlen=length(file)
  147.       xfile=right(xfile,xlen)
  148.       Address YAM "getmailinfo subject"      /* verify subject            */
  149.       xsubj=result      
  150.       xsubj=translate(xsubj,' ',',')
  151.       if file~=xfile | xsubj~=subj then do
  152.          Updlist.i.1.1.1.1=bo||_text._error
  153.       end 
  154.       else do
  155.          Updlist.i.1.1.1.1=bo||_text._deleted
  156.          Address YAM "maildelete" 
  157.       end
  158.    end
  159.    
  160.    do i=1 to Updlist.0
  161.       do j=0 to mcnt-1
  162.          list ID MLST POS j
  163.          mline=result
  164.          if mline='' then break
  165.          parse var mline arch ',' from ',' subj ',' mfor ',' mnum ',' anum ',' file
  166.          if Updlist.i=anum & Updlist.i.1=mnum then do
  167.             arch=Updlist.i.1.1.1.1
  168.             mline=arch||','||from||','||subj||','||mfor||','||mnum||','||anum||','||file
  169.             list ID MLST POS j STRING mline
  170.             iterate i
  171.          end
  172.       end
  173.    end
  174.  
  175.    window ID YTINF CLOSE
  176.  
  177. Return
  178.  
  179. /**************************************************************************/
  180. /*              Make sure YAM  and YAMTOOLS are running. Show YAM.        */
  181. /**************************************************************************/
  182. CheckYAM:
  183.  
  184.    if ~show('p','YAMTOOLS') then do
  185.       errmsg=_text._noyt
  186.       say errmsg
  187.       exit
  188.    end
  189.  
  190.    if ~show('p','YAM') then do
  191.       errmsg=_text._noyam
  192.       Call ErrorMsg
  193.       exit
  194.    end
  195.  
  196.    Address YAM 'show'                       /* uniconify YAM's screen     */  
  197.  
  198.     Address YAM 'info SCREEN'                /* get YAM's screen           */
  199.     screen=result
  200.     if screen='' then screen='Workbench'
  201.  
  202. Return
  203.  
  204. /******************************************************************************/
  205. /*  Display ERROR message and EXIT.                                           */
  206. /******************************************************************************/
  207. ErrorMsg:
  208.  
  209.    window ID YTINF CLOSE
  210.  
  211.    request ID ERRM GADGETS _text._ok errmsg
  212.  
  213.    exit
  214.  
  215. Return
  216.  
  217. /******************************************************************************/
  218. /*  Simple information/error message window.                                  */
  219. /******************************************************************************/
  220. InfoWindow:
  221.  
  222.    window ID YTINF TITLE _title._info ATTRS MUIA_Window_PublicScreen screen,
  223.           MUIA_Window_SizeGadget FALSE,
  224.           MUIA_Window_DepthGadget FALSE
  225.  
  226.       group 
  227.          group 
  228.             text ID STEXT HELP help.STEXT  NODE node.STEXT LABEL infotext
  229.          endgroup
  230.          if showbusy then do
  231.             group
  232.                object CLASS '"Busy.mcc"' ATTRS MUIA_VertWeight 25
  233.             endgroup
  234.          end
  235.          if infobuttons ~='' then do
  236.             group HORIZ
  237.                group 
  238.                   space HORIZ 
  239.                endgroup
  240.                group 
  241.                   radio ID SQUIT HELP help.SQUIT  NODE node.SQUIT LABELS infobuttons
  242.                endgroup
  243.                group 
  244.                   space HORIZ 
  245.                endgroup
  246.             endgroup
  247.          end
  248.          else do
  249.             group 
  250.                space HORIZ 100
  251.             endgroup
  252.          end
  253.       endgroup
  254.    endwindow
  255.  
  256. Return
  257.  
  258. /******************************************************************************/
  259. /*                      MUIREXX TAGS & VARIABLES                              */
  260. /******************************************************************************/
  261. Muivars:
  262.  
  263. MUIA_List_Entries =         0x80421654 
  264. MUIA_VertWeight =           0x804298d0 
  265. MUIA_Window_DepthGadget  =  0x80421923
  266. MUIA_Window_PublicScreen =  0x804278e4
  267. MUIA_Window_SizeGadget  =   0x8042e33d
  268.  
  269. TRUE=1
  270. FALSE=0
  271.  
  272. Return
  273. /**************************************************************************/
  274. /*           Various values used throughout the various routines          */
  275. /**************************************************************************/
  276. YTvars:
  277.  
  278. missing='.'
  279. bo='\033b'                                  /* print control BOLD         */
  280.  
  281. Return
  282.  
  283. /**************************************************************************/
  284. /*    Messages, text, etc. constructed using previously defined values    */
  285. /**************************************************************************/
  286. Builtvars:
  287.  
  288. Return
  289.  
  290. /**************************************************************************/
  291. /*               Pointers into the YamTools.guide documentation           */
  292. /**************************************************************************/
  293. Helpvars:
  294.  
  295. node.SQUIT='7.3.'
  296. node.STEXT='7.3.'
  297.  
  298. Return
  299.  
  300. /**************************************************************************/
  301. /*       Mui Gadgets, text, msgs, etc. used in YamTools                   */
  302. /**************************************************************************/
  303. Localize:
  304.  
  305. /*********************************/
  306. /* Miscellaneous info strings    */
  307. /*********************************/
  308. _title._main="""YTReFormat v1.0"""          /* main screen title          */
  309. _title._info="""YTDelete Info"""            /* default title on infomsg   */
  310.  
  311. _text._ok="Ok"                              /* various OK buttons         */
  312. _text._cancel="Cancel"                      /* LABEL for CANCEL button    */
  313. _text._squit1="Continue"                    /* CONTINUE option on infowin */
  314. _text._squit2="Interrupt"                   /* INTERRUPT option on infowin*/
  315. _text._squit3="Abort"                       /* ABORT    option on infowin */
  316. _text._error="error"                        /* error on deleting mail     */
  317. _text._deleted="Deleted"                    /* indicate mail deleted      */
  318.  
  319. _text._delmail="Deleting Mail..."           /* Deleting Mail message      */
  320. _text._delreq="""Delete selected entries?"""  /* delete request message   */
  321.  
  322.  
  323. /*********************************/
  324. /* Various error conditions      */
  325. /*********************************/
  326.  
  327. _text._noyam="You need YAM running to use YTDelete"    /* yam not running */
  328. _text._noyt="You need YAMTOOLS running to use YTDelete"   /* no yamtools  */
  329. _text._nomail="You need to CHOOSE mail to Delete"
  330.  
  331. Return
  332.  
  333.  
  334. /**************************************************************************/
  335. /*           Help Messages to display with MUI bubble facility.           */
  336. /*                                                                        */
  337. /* Format is simple: help.ID where ID is the id specified on the MUI      */
  338. /* object statement.                                                      */
  339. /* Similar approach for accessing the .guide information using the NODE   */
  340. /* option on the object statement.                                        */
  341. /*                                                                        */
  342. /**************************************************************************/
  343.  
  344. help.SQUIT=""""""
  345. help.STEXT=""""""
  346.  
  347. Return
  348.  
  349.  
  350.  
  351.  
  352.