# $language = "VBScript"
# $interface = "1.0"
' Script to add DSC's to an M1/CS1000 switch.
' Uses comma-delimited file C:\temp\cdp_new.csv with this format
' DSC,FLEN,RLI
' All other prompts are skipped.
' You need to be in LD 87 to start
Dim g_objTab, g_objLogFile
Set g_objTab = crt.GetScriptTab
Set g_objLogFile = CreateObject("Scripting.FileSystemObject")
' Define the amount of time (milliseconds) that should be introduced as
' a delay between each line being sent to the remote host.
g_nDelay = 500
Const ForAppending = 8
Const ForReading = 1
Sub main
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\temp\cdp_new.csv", ForReading, 0)
Dim line, params
' g_objTab.screen.Synchronous = True
' crt.Screen.Send chr(13)
Do Until f.AtEndOfStream
bDidOne = False
line = f.Readline
params = Split( line, "," )
Do Until bDidOne
Select Case This_Prompt
Case "REQ" Xmit "NEW"
Case "CUST" Xmit "0"
Case "FEAT" Xmit "CDP"
Case "TYPE" Xmit "DSC"
Case "DSC" Xmit params(0)
Case "FLEN" Xmit params(1)
Case "DSP" Xmit ""
Case "RLI" Xmit params(2)
Case "NPA" Xmit ""
Case "NXX" Xmit ""
bDidOne = True
Case Else Xmit ""
End Select
Loop
Loop
crt.Screen.WaitForCursor(1)
Xmit ""
g_objTab.screen.Synchronous = False
End Sub
Function This_Prompt
' The "This_Prompt" function returns the PBX prompt at the current cursor position
' Make sure the cursor has stopped moving
Do
bCursorMoved = crt.Screen.WaitForCursor(1)
Loop Until bCursorMoved = False
screenrow = g_objTab.screen.CurrentRow
This_Prompt = Trim(g_objTab.screen.Get(screenrow, 1, screenrow, 20))
End Function
'-----------------------------------------------------------------------------
Function Xmit(sCmd)
' The "Xmit" function replaces the CRT Send command.
' It simplifies sending commands to the PBX by adding
' the carriage return and pacing the command input.
g_objTab.screen.Send sCmd & chr(13)
End Function