And here's one that moves phones based upon a spreadsheet saved as a .csv. Bascially, it first reads the file line by line and outs all the "old" locations. It then reads through the same file again and builds phones on the "new" locations. Every time it builds a "new" phone it outs what's on that TN. It also handles MARP issues...
---------------------------------------------------------------------
proc main
string Fname ; String to contain file name.
string FileSpec ; String to contain file spec.
;string Attr ; String to contain attributes.
string linebuffer
string lineinfo
string lineparse
string Desi
string Ext1
string Ext2
string TN
string Phone_Type
integer counter
string TN_Old
string MCR
integer MCR_yes
integer added_mcr
integer count_all
;******************************************************************************
;****** CHANGED ON 6/16/04 TO REFLECT THE FOLLOWING SPREADSHEET CONFIG: *******
; DESI = 1
; OLD TN = 2
; NEW TN = 3
; DN1 = 4
; DN2 = 5
; MCR = 6
;******************************************************************************
;***********************************
;****** Open file from drive *******
;***********************************
FileSpec = "c:\*.*" ; Set spec to all files in "c:\".
dir FileSpec Fname ; Display dir and get file name.
if SUCCESS ; See if a file was chosen.
; Get and display attributes for chosen file.
;fileget Fname ATTRIBUTE Attr
;usermsg "Attributes for `"%s`" are `"%s`"." Fname Attr
endif
;************************************
;***** Read each line from file *****
;************************************
transmit "****"
transmit "^M"
transmit "LD 20^M"
if fopen 0 Fname READ TEXT ; Open file for read only.
while not feof 0 ; Loop while not end of file.
fgets 0 LineBuffer
lineinfo = LineBuffer
;******************************************
;****** Get Old TN info and out phone *****
;******************************************
strtok lineparse lineinfo "," 2
TN_Old = lineparse
strcat TN_Old "^M"
waitfor "REQ:"
transmit "disu "
transmit TN_Old
when TARGET 1 "OVL429 - OVERLAY CONFLICT." call overlay_conflict
waitfor "REQ:"
transmit "out^M"
waitfor "TYPE: "
transmit "2616^M"
waitfor "TN "
mspause 500
transmit TN_Old
when TARGET 0 "SCH0128" call enter_stars
endwhile
fclose 0 ; Close file opened for read.
else
errormsg "Couldn't open file `"%s`"." Fname
endif
if fopen 0 Fname READ TEXT ; Open file for read only.
while not feof 0 ; Loop while not end of file.
fgets 0 LineBuffer ; Get line from file.
;usermsg LineBuffer ; Display
lineinfo = LineBuffer
counter = 1
;***********************************
;***** Get each item in line *****
;***********************************
while 1 ; Loop forever, or until EXITWHILE.
strtok lineparse lineinfo "," 1 ; Get first item from data list.
if nullstr lineparse ; Check to see if item is null.
exitwhile ; If so, exit loop.
endif
switch counter
case 1
desi = lineparse
endcase
case 3
TN = lineparse
endcase
;REMOVED NCOS
;case 2
;Ncos = lineparse
;endcase
case 4
Ext1 = lineparse
endcase
case 5
Ext2 = lineparse
endcase
;REMOVED HFA
;case 5
;HFA = lineparse
;endcase
case 6
mcr = lineparse
endcase
endswitch
counter = counter + 1
;usermsg "Data item is `"%s`"." lineparse
endwhile
;*****************************
;***** Add ^M to each var ****
;*****************************
Phone_Type = "2616"
strcat Phone_Type "^M"
strcat TN "^M"
strcat desi "^M"
;strcat Ncos "^M"
;strcat Queue "^M"
;strcat acd "^M"
strcat Ext1 "^M"
strcat Ext2 "^M"
if strcmp mcr "3311"
mcr_yes = 1
else
mcr_yes = 0
endif
;*******************************
;** OUT ANY EXISTING PHONE **
;*******************************
transmit "^M"
transmit "*^M"
waitfor "REQ:"
transmit "disu "
transmit TN
waitfor "REQ:"
transmit "out^M"
waitfor "TYPE: "
transmit Phone_Type
waitfor "TN "
transmit TN
when TARGET 0 "SCH0128" call enter_stars
;*******************************
;** BUILD THE PHONE **
;*******************************
waitfor "REQ:"
transmit "new^M"
waitfor "TYPE: "
transmit Phone_Type
waitfor "TN "
transmit TN
waitfor "DES "
transmit desi
;waitfor "CTYP "
;transmit "^M"
waitfor "CUST "
transmit "0^M"
waitfor "AOM "
transmit "^M"
waitfor "FDN "
transmit "3123^M"
waitfor "TGAR "
transmit "1^M"
waitfor "LDN "
transmit "^M"
waitfor "NCOS "
transmit "4^M"
waitfor "RNPG "
transmit "^M"
waitfor "SSU "
transmit "^M"
waitfor "SGRP "
transmit "^M"
waitfor "CLS "
;transmit HFA
transmit " hta fna ira ola cnda fita lna mwa tdd ^M"
;transmit "^M"
waitfor "RCO "
transmit "^M"
waitfor "HUNT "
transmit "3123^M"
waitfor "LHK "
transmit "1^M"
waitfor "LNRS "
transmit "^M"
waitfor "SCI "
transmit "^M"
waitfor "LPK "
transmit "0^M"
waitfor "PLEV "
transmit "^M"
;waitfor "SPID "
;transmit "^M"
waitfor "AST "
transmit "^M"
waitfor "IAPG "
transmit "^M"
;waitfor "PRI "
;transmit "^M"
waitfor "MLWU_LANG " ;added 8/31/04 due to succession 3.0
transmit "^M"
waitfor "DNDR "
transmit "^M"
waitfor "KEY "
transmit "0 scr "
transmit Ext1
when TARGET 0 "MARP ON " call marp_entry
waitfor " CPND "
transmit "^M"
waitfor " VMB "
transmit "^M"
waitfor "KEY "
transmit "1 scr "
transmit Ext2
when TARGET 0 "MARP ON " call marp_entry
waitfor " CPND "
transmit "^M"
waitfor " VMB "
transmit "^M"
waitfor "KEY "
transmit "4 msb^M"
waitfor "KEY "
transmit "5 dsp^M"
waitfor "KEY "
transmit "8 ao6^M"
waitfor "KEY "
transmit "9 trn^M"
waitfor "KEY "
transmit "10 cfw 4^M"
;**************************
;** PUT IN MCR IF NEEDED **
if mcr_yes == 1
waitfor "KEY "
transmit "12 MCR 3311^M"
waitfor " CPND "
transmit "^M"
waitfor " VMB "
transmit "^M"
added_mcr = 1
endif
;**************************
waitfor "KEY "
transmit "14 mwk 3123^M"
waitfor "KEY "
transmit "^M"
Pause 2
count_all = count_all + 1
endwhile
fclose 0 ; Close file opened for read.
else
errormsg "Couldn't open file `"%s`"." Fname
endif
if added_mcr == 1
transmit "chg^M"
waitfor "TYPE: "
transmit "500^M"
waitfor "TN "
transmit "36 0 12 2^M"
waitfor "ECHG "
transmit "yes^M"
waitfor "ITEM "
transmit "dn 3311^M"
waitfor " MARP "
transmit "yes^M"
waitfor " CPND "
transmit "^M"
waitfor " VMB "
transmit "^M"
waitfor "ITEM "
transmit "^M"
endif
usermsg "Jeez Louise, I just moved %d phones!!" count_all
endproc
proc enter_stars
waitfor "TN "
mspause 500
transmit "***^M"
endproc
proc overlay_conflict
usermsg "Sorry, there's an overlay conflict"
exit
endproc
proc marp_entry
waitfor "MARP "
transmit "^M"
endproc