home *** CD-ROM | disk | FTP | other *** search
- @echo off
- : phone.btm -- phone dialing for %dbpath\db free form database
- : Selects matching db lines to dial. Uses default prefix **
- : to mark number in db line (e.g. john doe ** 555-1212 ).
- : If no ** or prfix supplied, accepts your prefix string interactively.
- :
- : Uses dial.btm, and sets up "dial" env variable to last value selected
- : Optionally dials it, or exits.
- :
- : History:
- : 08-Apr-92 MGiguere Now writes phonetmp to %temp4dos.
- : 08-Apr-92 MGiguere Now just dials assuming ** prefix.
- : 10-Mar-92 MGiguere Selections displayed as a pop-up window.
- : 09-Mar-92 MGiguere Added code to handle local vs. long distance.
- : 08-Mar-92 MGiguere Path to DB now env. var.
- : 05-Mar-92 MBarrett Created.
- :
- iff .%1==. then
- echo Usage: phone [key phrase] [prefix]
- goto exit
- endiff
- fgrep /i "%1" %dbpath\db | fgrep /i "%2" >%temp4dos\phonetmp
- if %@filesize[%temp4dos\phonetmp,b] EQ 0 goto exit
- : create a pop-up menu of records that match pattern string if needed.
- set l=%@eval[1+%@lines[%temp4dos\phonetmp]]
- set dial=%@select[%temp4dos\phonetmp,5,5,%@eval[%l+7],75, Phone - %l selected ]
- if "%dial" == "" goto exit
- iff .%2==. then
- set ans=**
- else
- set ans=%2
- endiff
- : extract phone number from selected record.
- set dial=%@substr[%dial,%@eval[%@index[%dial,%ans]+%@len[%ans]]]
- gosub num_prefix
- call dial %dial
- :exit
- del/q %temp4dos\phonetmp
- unset dial l ans >& NUL
- quit
- :
- :num_prefix
- : Checks to see if number is local or long distance call.
- : Assumes phone numbers in the form: (###)-###-#### or ###-###-####.
- : International numbers assumed prefixed with 011-
- : Escape prefix: "." prefixed numbers are returned as is sans the "."
- : The contents of the variable "prefix" are prepended to numbers.
- : History:
- : 13-Mar-92 MGiguere Added dialing prefix code
- : 09-Mar-92 MGiguere area codes in form (###)|### now acceptable.
- : 06-Mar-92 MGiguere Created.
- iff %@index[%dial,.] == 0 then
- set dial=%@substr[%dial,1]
- return
- endiff
- : prefix = dialing prefix
- set prefix=
- : ac = area code local
- set ac=508
- : dc = local district codes comma separated
- set dc=392,425,433,448,486,582,597,649,692,772,796,952
- : check area code for long distance call
- set i=%@index[%dial,%ac]
- iff %i == 0 .OR. %i == 1 then
- set dial=%prefix%%@substr[%dial,%@eval[4+(%i*2)]]
- : call outside local district?
- if %@index["%dc",%@substr[%dial,0,3]] == -1 set dial=%prefix%1-%dial
- else
- : International call?
- if %@index[%dial,011-] == -1 set dial=%prefix%1-%dial
- endiff
- unset ac dc i prefix >& NUL
- return
-