Netguard3
-
Total Posts
:
14
- Scores: 0
-
Reward points
:
0
- Joined: 5/12/2005
- Location: Denmark
-
Status: offline
|
Printers/read info from file
Thursday, May 12, 2005 7:57 PM
( permalink)
Hey Guys :) searched the forum, but whitout luck. I have this script: dim oPort dim oMaster set oPort = CreateObject("Port.Port.1") set oMaster = CreateObject("PrintMaster.PrintMaster.1") oPort.PortName = "IP_10.10.2.14" oPort.PortType = 1 oMaster.PortAdd oPort if Err <> 0 then msgbox "There was an error creating the port." end if i have the Ips, porttypes in a txt file. how can i make it read it from there? I have aroudn 50 printers listed in one file. any ideas?
|
|
|
|
mbouchard
-
Total Posts
:
2110
- Scores: 29
-
Reward points
:
0
- Joined: 5/15/2003
- Location: USA
-
Status: offline
|
Re: Printers/read info from file
Friday, May 13, 2005 1:46 AM
( permalink)
You have several options, all depending on how the info is in the text file. If it is a comma delaminated, you can use readline, then use split to seperate the IP and porttypes. Or, you can use readall, split that into an array then split each line into another array. Here is a example on how to do the second option
Const FORREADING = 1
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
'Open text file for reading
Set f = fso.OpenTextFile("test.txt", ForReading)
'Read the file into a variable
theFile = f.ReadAll
'Split TheFile variable into an array, using vbcrlf as the delimiter
MyArray = split(theFile,vbcrLF)
'Parse through the Array
For I = 0 to Ubound(MyArray)
'Create Array for each line in file
MyArray2 = Split(MyArray(I),",")
ipAddress = MyArray2(0)
portType = MyArray2(1)
'Do what you need to do here.
msgbox "IpAddress = " & ipAddress & vbcr & "Port Type = " & portType
Next
|
|
|
|
Netguard3
-
Total Posts
:
14
- Scores: 0
-
Reward points
:
0
- Joined: 5/12/2005
- Location: Denmark
-
Status: offline
|
Re: Printers/read info from file
Friday, May 13, 2005 2:30 AM
( permalink)
Thx mate, that really helped alot :) is there away to clear the array after each line? Getting the error: Subscript out of Range: '[Number: 0]' when the script is done. but it completes the process :)
|
|
|
|
Netguard3
-
Total Posts
:
14
- Scores: 0
-
Reward points
:
0
- Joined: 5/12/2005
- Location: Denmark
-
Status: offline
|
Re: Printers/read info from file
Tuesday, May 17, 2005 1:22 AM
( permalink)
|
|
|
|