home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / comm / mail / YAMscripts.lha / search.rexx < prev    next >
OS/2 REXX Batch file  |  1997-02-05  |  3KB  |  114 lines

  1. /*                        Search.rexx
  2.                 v1.1 - 05-Feb-97
  3.  
  4. The script now displays a requester every time when the search word is found.
  5. You can read the message and then click on continue search.
  6.  
  7. Send comments, suggestions, bug reports and e-money to knikulai@utu.fi
  8. Remember to check http://www.utu.fi/~knikulai/ARexx.html for more scripts and new
  9. versions
  10.  
  11. */
  12. options results
  13. call addlib('rexxreqtools.library',0,-30)
  14.  
  15.      title='Search.rexx by Kai.Nikulainen@utu.fi © 1996'
  16. search_txt='Enter search word:'
  17.  start_txt='Where should I start the search?'
  18.  start_but='_First message|_Here|_Cancel'
  19.  where_txt='From which messages you want to search?'
  20.  where_but='_All|_Read|_Unread|_Not Replied|Cancel'
  21.  found_txt='Word was found in this message'
  22.  found_but='_Continue search|_End search'
  23.     header='unchecked messages with word "'
  24.    sel_but='_Scroll|_Done'
  25.  
  26. maxmsg=9        /* Number of messages in one requester */
  27. NL='0a'x        /* newline */
  28.  
  29. sana=rtgetstring('',search_txt,title)
  30. if sana='' then exit
  31. u_sana=upper(sana)
  32. sel=rtezrequest(where_txt,where_but,title,'rtez_defaultresponse=1')
  33. if sel=0 then exit
  34. types='ONUR'
  35. if sel=2 then types='OR'
  36. if sel=3 then types='UN'
  37. if sel=4 then types='ONU'
  38.  
  39. address 'YAM'
  40. firstmsg=0
  41.  
  42. sel=rtezrequest(start_txt,start_but,title,'rtez_defaultresponse=1')
  43. if sel=0 then exit
  44. if sel=2 then do
  45.     'GetMailInfo Active'
  46.     firstmsg=result
  47.     end
  48.  
  49. 'GetFolderInfo Max'
  50. n=result
  51. mc=0
  52. do m=firstmsg to n-1
  53.    'SetMail' m
  54.    'GetMailInfo Status'
  55.    if pos(result,types)>0 then do  
  56.       'GetMailInfo File'
  57.       call open(in,result,r)
  58.       found=0
  59.       do until eof(in) | found>0
  60.          rivi=readln(in)
  61.      found=pos(u_sana,upper(rivi))
  62.       end /* do until */
  63.       call close(in)
  64.       if found>0 then do /* Add this message to the list and display a requester*/
  65.          mc=mc+1
  66.      msgnum.mc=m
  67.      'GetMailInfo Subject'
  68.      msgsub.mc=result
  69.      sel=rtezrequest(found_txt,found_but,title,'rtez_defaultresponse=1')
  70.      if sel=0 then exit
  71.      end /* if found>0 */
  72.    end /* if pos(result,types)>0 then do */
  73. end /* do m=0 to n-1 */
  74.  
  75. curtop=1
  76. do until mc=0
  77.    if mc<=maxmsg then do
  78.        curtop=1
  79.     curbot=mc
  80.     num=mc
  81.     end
  82.    else do
  83.         curbot=curtop+maxmsg-1   
  84.     num=maxmsg
  85.     end
  86.    body=mc header || sana || '"' || NL
  87.    buttons=''
  88.    do i=curtop to curbot
  89.       j=i-curtop+1
  90.       buttons=buttons ||'_' || j || '|'
  91.       ind=1+i//mc
  92.       body=body || j ') ' msgsub.ind || NL
  93.       butnum.j=msgnum.ind
  94.       butind.j=ind
  95.    end /* do i=curtop to curbot */
  96.    buttons=buttons || sel_but
  97.    sel=rtezrequest(body,buttons,title,'rtez_defaultresponse=0')
  98.    if sel=0 then exit
  99.    if sel=num+1 then do
  100.        curtop=curtop+maxmsg
  101.     if curtop>mc then curtop=curtop-mc
  102.     end
  103.    else do /* A message was selected */
  104. say 'butind.sel=' butind.sel 'mc=' mc
  105.       'SetMail' butnum.sel
  106.       do i=butind.sel to mc-1
  107.          k=i+1
  108.          msgnum.i=msgnum.k
  109.      msgsub.i=msgsub.k
  110.      end
  111.       mc=mc-1
  112.    end /* else */
  113. end /* do until mc=0 */
  114.