home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / biz / dfa-2.0.lha / DFA / Rexx / Call.rexx < prev    next >
OS/2 REXX Batch file  |  1994-02-23  |  5KB  |  142 lines

  1. /************************************************************************/
  2. /*  Call.rexx                                  by Frank Pecher          */
  3. /*                                                                      */
  4. /*  Call a person with DFA                                              */
  5. /*                                                                      */
  6. /*  Syntax:                                                             */
  7. /*      Call <First|Name>                                               */
  8. /*                                                                      */
  9. /*  You will be shown the found person and be prompted for dialing, so  */
  10. /*  you can be sure to call the correct number if the same person has   */
  11. /*  more than one phone number.                                         */
  12. /*      When prompted, you have the following options how to continue:  */
  13. /*      * q(uit)<CR>  don't look for further matches.                   */
  14. /*      * n(o)<CR>    find next match.                                  */
  15. /*      * y(es)<CR>   dial found number                                 */
  16. /*      This script will take care to dial the numbers as short as      */
  17. /*  possible, so if you call somebody with the same dial prefix, the    */
  18. /*  prefix will not be dialled.                                         */
  19. /*      See below how to customize this script for your purposes.       */
  20. /************************************************************************/
  21.  
  22. /*
  23. **  LOCAL DIAL PREFIXES: if these are found in the database, they will
  24. **  be ommited when dialling. EDIT THESE so that they match the codes of
  25. **  your country/region.
  26. **
  27. **  This batch expects phone codes of the form
  28. **
  29. **      +49 (0)7031 278606
  30. **      ^   ^       ^
  31. **      |   |       |
  32. **      |   |       personal phone number
  33. **      |   regional pre-code
  34. **      |   the parentheses around the zero mean that it will be
  35. **      |   omitted when the country precode of the found number
  36. **      |   does not match LOCAL_COUNTRY (see below)
  37. **      |
  38. **      country pre-code; the '+' will be replaced by LOCAL_OUT (see below)
  39. **
  40. **  EXAMPLES:
  41. **      My own settings:    LOCAL_OUT     = "0"
  42. **                          LOCAL_COUNTRY = "+49"
  43. **                          LOCAL_REGION  = "(0)7031"
  44. **                          LOCAL_NUMBER  = "278608"
  45. **
  46. **  *   Found number:       +49 (0)7031 278608
  47. **      Call.rexx dials nothing and displays an error message.
  48. **
  49. **  *   Found number:       +49 (0)7031 12345
  50. **      Call.rexx dials:    12345
  51. **
  52. **  *   Found number:       +49 (0)805  11223
  53. **      Call.rexx dials:    0805 11223
  54. **
  55. **  *   Found number:       +11 (0)321  90807
  56. **      Call.rexx dials:    011 321 90807
  57. */
  58.  
  59. LOCAL_OUT     = "0"
  60. LOCAL_COUNTRY = "+49"
  61. LOCAL_REGION  = "(0)931"
  62. LOCAL_NUMBER  = "286914"
  63.  
  64.  
  65. parse arg person
  66. person = upper(strip(person))
  67.  
  68. options RESULTS
  69.  
  70. say "Searching..."
  71.  
  72. address "DFA" first stem p.
  73.  
  74. do while RC = 0
  75.     Ignore = 0
  76.  
  77.     name = upper(strip(p.address.2))
  78.     first = upper(strip(p.address.1))
  79.     comment = upper(p.address.15)
  80.  
  81.     if (find(name, person) ~= 0) | (find(first, person) ~= 0) | (find(comment, person) ~= 0) then
  82.     do
  83.         say "Found "p.address.1 p.address.2
  84.         say "      "p.address.4 p.address.5 p.address.6
  85.         say "      "p.address.10
  86.         say
  87.  
  88.         writech(stdout, "Dial [Ynq] ? ")
  89.  
  90.         pull answer
  91.  
  92.         answer = upper(left(answer, 1))
  93.  
  94.         if answer ~= "N" & answer ~= "Q" then
  95.             answer = "Y"
  96.  
  97.         if answer = "Y" then
  98.         do
  99.             origphone = p.address.10
  100.             parse var origphone country " " region " " number
  101.             parse var region "(" regopt ")" regcode
  102.  
  103.             if country ~= LOCAL_COUNTRY then
  104.                 phone = LOCAL_OUT||strip(country, L, "+")" "regcode" "number
  105.             else
  106.             do
  107.                 if region ~= LOCAL_REGION then
  108.                     phone = regopt||regcode" "number
  109.                 else
  110.                 do
  111.                     if number ~= LOCAL_NUMBER then
  112.                         phone = number
  113.                     else
  114.                     do
  115.                         say
  116.                         say "ERROR"
  117.                         say "   Either you were trying to call yourself or"
  118.                         say "   you haven't edited Call.rexx yet."
  119.                         say
  120.  
  121.                         Ignore = 1
  122.                     end
  123.                 end
  124.             end
  125.  
  126.             if Ignore = 0 then
  127.             do
  128.                 address "DFA" edit 'phone="'phone'"'
  129.                 address "DFA" dial
  130.                 address "DFA" edit 'phone="'origphone'"'
  131.                 exit
  132.             end
  133.         end
  134.         else
  135.         if answer = "Q" then
  136.             exit
  137.     end
  138.     address "DFA" next stem p.
  139. end
  140.  
  141. exit
  142.