#1
|
|||
|
|||
VBS Scripting newbie
I normally work in ProComm but am required to now use SecureCRT so I'm asking for a little help. I have a script that I need to create and have the basics of what I'm trying to do but am not sure how to script to read multiple lines from a text file and insert in a particular point in the script.
In the script below I need to read from a text file the phTYPE and the setTN and then repeat the Sub Main and read the next line in the text file for both phTYPE and set TN until the end of the text file can I use one text file or are two required required? any assistance would be much appreciated. #$language = "VBScript" #$interface = "1.0" crt.Screen.Synchronous = True ' Begin script ' edited version 4 DIM phTYPE ' Enter Phone TYPE in quotes below phTYPE = "2050PC" Sub Main crt.Screen.Send "****ld 20" & chr(13) crt.Screen.WaitForString "REQ: " crt.Screen.Send "chg" & chr(13) crt.Screen.WaitForString "TYPE: " crt.Screen.Send phTYPE & chr(13) crt.Screen.WaitForString "TN " crt.Screen.Send setTN & chr(13) crt.Screen.WaitForString "ECHG " crt.Screen.Send "yes" & chr(13) crt.Screen.WaitForString "ITEM " crt.Screen.Send "fdn 59248" & chr(13) crt.Screen.WaitForString "ITEM " crt.Screen.Send "hunt 59248" & chr(13) crt.Screen.WaitForString "ITEM " crt.Screen.Send "key 16 mwk 59990" & chr(13) crt.Screen.WaitForString " KEY " crt.Screen.Send chr(13) crt.Screen.WaitForString "ITEM " crt.Screen.Send chr(13) End Sub DIM setTN ' Enter the TN in quotes below setTN = "252 1 15 29" |
#2
|
|||
|
|||
Hi aramirez148,
I created one file with the format of: Code:
phTYPE0:::setTN0 phTYPE1:::setTN1 phTYPE2:::setTN2 phTYPE3:::setTN3 Code:
'Get ready to read from file Const ForReading = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objOpen = objFSO.OpenTextFile("C:\Path\to\file.txt", ForReading) 'Read contents of file and split into individual lines strFileContent = objopen.ReadAll arrLines = Split(strFileContent, vbcrlf) 'Clean up after reading file objOpen.Close Set objOpen = Nothing Set objFSO = Nothing 'For every line in file... For i = 0 to UBound(arrLines) 'Split each line using ::: as separator arrTypeTN = Split(arrLines(i), ":::") strTYPE = arrTypeTN(0) strTN = arrTypeTN(1) crt.Dialog.MessageBox("phTYPE = " & strType & vbcr & _ "setTN = " & strTN) Next
__________________
Thanks, --Eric VanDyke Software Technical Support support@vandyke.com (505) 332-5730 Last edited by ekoranyi; 06-11-2018 at 04:07 PM. |
![]() |
Tags |
csv , file calling , script |
Thread Tools | |
Display Modes | Rate This Thread |
|
|