home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / software / utilities / ttmanager / rexx / ttm-ttsearch.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1999-05-30  |  1.7 KB  |  73 lines

  1. /* $VER: TTM-TTSearch.rexx 1.0 (30.5.99) by J. Tierney
  2.  
  3.   TTManager Tooltype Search  v1.0
  4.   5/30/99  J. Tierney
  5.  
  6.   Function:  Searches the tooltype list for a string.
  7.  
  8.   Usage:  TTM-TTSearch.rexx [<test>]
  9.  
  10.           <test> - A - Test the entire tooltype string.  Default.
  11.                    K - Test only the tooltype keyword (left of the "=").
  12.                    D - Test only the tooltype data (right of the "=").
  13.  
  14.   Requires:  reqtools.library
  15.              rexxreqtools.library
  16. */
  17.  
  18. OPTIONS RESULTS
  19. ADDRESS 'TTMANAGER'
  20.  
  21. ARG opt .
  22.  
  23. IF ~SHOW('L', 'rexxreqtools.library') THEN DO
  24.   IF ~ADDLIB('rexxreqtools.library', 0, -30) THEN DO
  25.     SAY 'Could not open "rexxreqtools.library".'
  26.     EXIT 10
  27.   END
  28. END
  29.  
  30. 'GETTTLISTTOTAL'
  31. ttcount = result
  32. IF (rc = 5) | (ttcount = 0)  THEN EXIT 0   /* No open window or tooltypes. */
  33.  
  34. IF opt = 'K' THEN srchtype = ' - Keywords Only'
  35. ELSE IF opt = 'D' THEN srchtype = ' - Data Only'
  36. ELSE srchtype = ''
  37. oldpat = GETCLIP('TTMFindPat')
  38. pat = RTGETSTRING(oldpat, 'Text to search for:', 'Tooltype Search' || srchtype, 'From Top|From Current|Cancel','rt_reqpos=reqpos_centerscr')
  39. pat = UPPER(pat)
  40.  
  41. IF rtresult ~= 0 THEN DO
  42.   CALL SETCLIP('TTMFindPat', pat)
  43.  
  44.   IF rtresult = 2 THEN DO
  45.     'GETTTLISTCURRENT'
  46.     crnt = result + 1
  47.     END
  48.   ELSE crnt = 0
  49.  
  50.   match = 0
  51.   DO WHILE crnt < ttcount
  52.     'GETTOOLTYPE' crnt
  53.     ttype = UPPER(result)
  54.     x = POS('=', ttype)
  55.     IF (opt = 'K') & (x ~= 0) THEN ttype = LEFT(ttype, x - 1)  /* Only keyword. */
  56.     IF opt = 'D' THEN DO
  57.       /* Only Data. */
  58.       IF x ~= 0 THEN ttype = SUBSTR(ttype, x + 1)
  59.       ELSE ttype = ''
  60.     END
  61.  
  62.     match = POS(pat, ttype)
  63.     IF match ~= 0 THEN LEAVE
  64.  
  65.     crnt = crnt + 1
  66.   END
  67.  
  68.   IF match ~= 0 THEN 'SETTTLISTCURRENT' crnt
  69. END
  70.  
  71. CALL REMLIB('rexxreqtools.library')
  72.  
  73.