home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / callbycall < prev    next >
Text File  |  2020-01-01  |  3KB  |  90 lines

  1. ; c a l l b y c a l l
  2. ; A dialing script that selects an access code by time of day to get
  3. ; the lowest rate (this script is used in Muenchen/Munich, Germany).
  4. ;
  5. ; Sample usage:
  6. ;   set dial macro call-by-call
  7. ;   dial <phone-number>
  8. ;
  9. ; Illustrates:
  10. ;   An application for SET DIAL MACRO.
  11. ;   Regular expressions as SWITCH labels.
  12. ;   Word splitting.
  13. ;
  14. ; Version 1: 16 July 1999
  15. ;   Provider arrays are hardwired.
  16. ;   A future version will construct the provider arrays dynamically from
  17. ;   current rate tables, and possibly account for weekends/holidays.
  18. ;
  19. ; From: Peter Eichhorn <petere@assyst-intl.com>
  20. ; Organization: assyst GmbH
  21. ; URL: http://www.assyst-intl.com/
  22. ; Subject: Call-By-Call demo script
  23. ; Date: Fri, 16 Jul 99 18:34:32 MESZ
  24. ;
  25. ; Declare arrays with an element for each hour.
  26. ; \&d for the normal days and \&w for the weekend.
  27. ; (&w is currently not used.  We don't work on summer weekends :-)
  28. ; (Hint: use \v(nday) to get day of week: 0 = Sunday, 1 = Monday, ...)
  29. ;
  30. ; Each array element is a list of access codes to be dialed in that hour.
  31. ; The elements of the list are separated by spaces.  The first one is called
  32. ; on the first DIAL attempt; the second one on the second attempt, and so on.
  33. ;
  34. declare \&d[24]                 ; Weekdays
  35. declare \&w[24]                 ; Weekend (not used)
  36.  
  37. .\&d[7] = 01040 01078 01079     ; For 07:00-08:00
  38. .\&d[8] = 01079 01030 01051     ; For 08:00-09:00
  39.  
  40. for \%i 9 16 1 { .\&d[\%i] = 01051 010050 01030 }  ; For 09:00-17:00
  41.  
  42. .\&d[17] = 01066 01051 010050   ; For 17:00-18:00
  43. .\&d[18] = 01066 01030 01085    ; For 18-19
  44. .\&d[19] = 01019 01050 01066    ; For 19-20
  45. .\&d[20] = 01078 01015 01019    ; For 20-21
  46. .\&d[21] = 01011 01090 01040    ; For 21-22
  47.  
  48. for \%i 22 24 1 { .\&d[\%i] = 01050 01019 01011 }  ; For 22:00-07:00
  49. for \%i  1  6 1 { .\&d[\%i] = 01050 01019 01011 }
  50.  
  51. ; In this example, we have three provider numbers in each time slot,
  52. ; so we set the retry limit to 4, so on the 4th try we dial without
  53. ; specifying a provider.
  54. ;
  55. set dial retries 4
  56.  
  57. ; Since we are dialing a different number each time, there is no need to
  58. ; wait between dial attempts.
  59. ;
  60. set dial interval 2
  61.  
  62. ; Select and insert a provider access number depending on the current hour.
  63. ; Note that we skip all local calls (1-9*) and all calls that go to a nearby
  64. ; area (08*).
  65. ;
  66. define Call-By-Call {
  67.     ; First split the current number at 'w' or 'W' into two parts.
  68.     ;  BUT put the 'W' back in the first part!
  69.     ;  (W = "wait for secondary dialtone")
  70.     assign d_pre \fword(\%1,1,wW)W
  71.     assign d_num \fltrim(\%1,\m(d_pre))
  72.     ;;; echo \%1 \m(d_pre) \m(d_num) ; (debugging)
  73.  
  74.     ; For local calls or near-local calls use default provider.
  75.     ; Just return the number as given
  76.     switch \m(d_num) {
  77.        :[1-9]*, :08*, return \%1
  78.     }
  79.  
  80.     ; Get the current hour and if we have 00:xx make it 24.
  81.     assign hour \fword(\v(time))
  82.     if = 0 \m(hour) assign hour 24
  83.  
  84.     ; Finally return the original number including the dialing code 
  85.     ; for the new provider.  NOTE: A different access code is selected
  86.     ; for each dial attempt, \v(dialcount).
  87.     return \m(d_pre) \fword(\&d[\m(hour)],\v(dialcount)) \m(d_num)
  88. }
  89.