Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-11-2018, 02:54 PM
aramirez148 aramirez148 is offline
Registered User
 
Join Date: Jun 2018
Posts: 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"
Reply With Quote
  #2  
Old 06-11-2018, 03:52 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi aramirez148,

I created one file with the format of:

Code:
phTYPE0:::setTN0 
phTYPE1:::setTN1
phTYPE2:::setTN2
phTYPE3:::setTN3
Using the below code I am able to loop through each line in the file and separate out the phTYPE and setTN.

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
Does this help get you the behavior you're looking for?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by ekoranyi; 06-11-2018 at 04:07 PM.
Reply With Quote
Reply

Tags
csv , file calling , script

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 10:05 AM.