home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 199 / 4PHONE.ZIP / PHONE.BTM < prev   
Encoding:
Text File  |  1992-04-08  |  2.5 KB  |  74 lines

  1. @echo off
  2. :     phone.btm    -- phone dialing for %dbpath\db free form database
  3. :     Selects matching db lines to dial.  Uses default prefix **
  4. :     to mark number in db line (e.g. john doe ** 555-1212 ).
  5. :     If no ** or prfix supplied, accepts your prefix string interactively.
  6. :
  7. :     Uses dial.btm, and sets up "dial" env variable to last value selected
  8. :    Optionally dials it, or exits.
  9. :
  10. :    History:
  11. :    08-Apr-92    MGiguere    Now writes phonetmp to %temp4dos.
  12. :    08-Apr-92    MGiguere    Now just dials assuming ** prefix.
  13. :    10-Mar-92    MGiguere    Selections displayed as a pop-up window.
  14. :    09-Mar-92    MGiguere    Added code to handle local vs. long distance.
  15. :    08-Mar-92    MGiguere    Path to DB now env. var.
  16. :    05-Mar-92    MBarrett    Created.
  17. :    
  18. iff .%1==. then
  19.     echo Usage: phone [key phrase] [prefix]
  20.     goto exit
  21. endiff
  22. fgrep /i "%1" %dbpath\db | fgrep /i "%2" >%temp4dos\phonetmp
  23. if %@filesize[%temp4dos\phonetmp,b] EQ 0 goto exit
  24. :    create a pop-up menu of records that match pattern string if needed.
  25. set l=%@eval[1+%@lines[%temp4dos\phonetmp]]
  26.     set dial=%@select[%temp4dos\phonetmp,5,5,%@eval[%l+7],75, Phone - %l selected ]
  27.     if "%dial" == "" goto exit
  28. iff .%2==. then
  29.     set ans=**
  30. else
  31.     set ans=%2
  32. endiff
  33. :    extract phone number from selected record.
  34. set dial=%@substr[%dial,%@eval[%@index[%dial,%ans]+%@len[%ans]]]
  35. gosub num_prefix
  36. call dial %dial
  37. :exit
  38. del/q %temp4dos\phonetmp
  39. unset dial l ans >& NUL
  40. quit
  41. :
  42. :num_prefix
  43. :    Checks to see if number is local or long distance call.
  44. :    Assumes phone numbers in the form: (###)-###-#### or ###-###-####.
  45. :    International numbers assumed prefixed with 011-
  46. :    Escape prefix: "." prefixed numbers are returned as is sans the "."
  47. :    The contents of the variable "prefix" are prepended to numbers.
  48. :    History:
  49. :    13-Mar-92    MGiguere    Added dialing prefix code
  50. :    09-Mar-92    MGiguere    area codes in form (###)|### now acceptable.
  51. :    06-Mar-92    MGiguere    Created.
  52. iff %@index[%dial,.] == 0 then
  53.     set dial=%@substr[%dial,1]
  54.     return
  55. endiff
  56. :    prefix = dialing prefix
  57. set prefix=
  58. :  ac = area code local
  59. set ac=508
  60. :  dc = local district codes comma separated
  61. set dc=392,425,433,448,486,582,597,649,692,772,796,952
  62. :  check area code for long distance call
  63. set i=%@index[%dial,%ac]
  64. iff %i == 0 .OR. %i == 1 then
  65.     set dial=%prefix%%@substr[%dial,%@eval[4+(%i*2)]]
  66. :  call outside local district?
  67.     if %@index["%dc",%@substr[%dial,0,3]] == -1 set dial=%prefix%1-%dial
  68. else
  69. : International call?
  70.     if %@index[%dial,011-] == -1 set dial=%prefix%1-%dial
  71. endiff
  72. unset ac dc i prefix >& NUL
  73. return
  74.