; c a l l b y c a l l ; ; A dialing script that selects an access code by time of day to get ; the lowest rate (this script is used in Muenchen/Munich, Germany). ; ; Sample usage: ; set dial macro call-by-call ; dial ; ; Illustrates: ; An application for SET DIAL MACRO. ; Regular expressions as SWITCH labels. ; Word splitting. ; ; Version 1: 16 July 1999 ; Provider arrays are hardwired. ; A future version will construct the provider arrays dynamically from ; current rate tables, and possibly account for weekends/holidays. ; ; From: Peter Eichhorn ; Organization: assyst GmbH ; URL: http://www.assyst-intl.com/ ; Subject: Call-By-Call demo script ; Date: Fri, 16 Jul 99 18:34:32 MESZ ; ; Declare arrays with an element for each hour. ; \&d for the normal days and \&w for the weekend. ; (&w is currently not used. We don't work on summer weekends :-) ; (Hint: use \v(nday) to get day of week: 0 = Sunday, 1 = Monday, ...) ; ; Each array element is a list of access codes to be dialed in that hour. ; The elements of the list are separated by spaces. The first one is called ; on the first DIAL attempt; the second one on the second attempt, and so on. ; declare \&d[24] ; Weekdays declare \&w[24] ; Weekend (not used) .\&d[7] = 01040 01078 01079 ; For 07:00-08:00 .\&d[8] = 01079 01030 01051 ; For 08:00-09:00 for \%i 9 16 1 { .\&d[\%i] = 01051 010050 01030 } ; For 09:00-17:00 .\&d[17] = 01066 01051 010050 ; For 17:00-18:00 .\&d[18] = 01066 01030 01085 ; For 18-19 .\&d[19] = 01019 01050 01066 ; For 19-20 .\&d[20] = 01078 01015 01019 ; For 20-21 .\&d[21] = 01011 01090 01040 ; For 21-22 for \%i 22 24 1 { .\&d[\%i] = 01050 01019 01011 } ; For 22:00-07:00 for \%i 1 6 1 { .\&d[\%i] = 01050 01019 01011 } ; In this example, we have three provider numbers in each time slot, ; so we set the retry limit to 4, so on the 4th try we dial without ; specifying a provider. ; set dial retries 4 ; Since we are dialing a different number each time, there is no need to ; wait between dial attempts. ; set dial interval 2 ; Select and insert a provider access number depending on the current hour. ; Note that we skip all local calls (1-9*) and all calls that go to a nearby ; area (08*). ; define Call-By-Call { ; First split the current number at 'w' or 'W' into two parts. ; BUT put the 'W' back in the first part! ; (W = "wait for secondary dialtone") assign d_pre \fword(\%1,1,wW)W assign d_num \fltrim(\%1,\m(d_pre)) ;;; echo \%1 \m(d_pre) \m(d_num) ; (debugging) ; For local calls or near-local calls use default provider. ; Just return the number as given switch \m(d_num) { :[1-9]*, :08*, return \%1 } ; Get the current hour and if we have 00:xx make it 24. assign hour \fword(\v(time)) if = 0 \m(hour) assign hour 24 ; Finally return the original number including the dialing code ; for the new provider. NOTE: A different access code is selected ; for each dial attempt, \v(dialcount). return \m(d_pre) \fword(\&d[\m(hour)],\v(dialcount)) \m(d_num) }