-
Mar 29th, 2012, 07:41 PM
#1
Thread Starter
New Member
type Mismatch problemt
Hi i hope this is the right place to post this
In my master thesis i am trying to fetch some data from a simulated model made in an program named PIPESIM.
"PIPESIM has been designed with "Openness" in mind. Therefore key modules can be "driven" from 3rd party applications, for example, Microsoft Excel, VB, C++, and so on."
I am using VBScript because i am using a runner to change arguments of the script. (Running with many different innputs/files
one of the calls/commands i make is .GetNameList ()
The error i get is:
Line: 81 Column: 1
Error: Type mismatch: 'netModel.GetNameList'
Code: 800A000D
Source: Microsoft VBScript runtime error
System: The data is invalid.
From the documentation of Pipesim:
GetNameList (ObjectType As Long, pNameArray, Count As Long)
Returns in pNameArray an array of String with the names of objects of the given type (ObjectType). The number of objects found is returned in Count.
ObjectType can be any of:
1 - Folder
2 - Source
3 - Sink
4 - Junction
5 - Branch
6 - Text Object
7 - Production Well
8 – Injection Well
Here is my code:
Code:
' **** "Generic" Task's ******************************************'
' Check And invoke working directory (Disable when not code testing)
Set WshShell = WScript.CreateObject ("WScript.Shell")
WScript.Echo (WshShell.CurrentDirectory)
WshShell.CurrentDirectory = "C:\VBA Test Enviorment"
WScript.Echo (WshShell.CurrentDirectory)
path = WshShell.CurrentDirectory
' Check and show for arguments
args = WScript.Arguments.Count
' Check
If args < 1 then
WScript.Echo "usage: Example1.vbs user_data_file pipesim_inp_file user_ressults_file"
WScript.Quit(1)
end If
'Show (Disable when not code testing)
WScript.Echo "You entered " & args & " Arguments, the first was "_
& chr(34) & WScript.Arguments.Item(0) & Chr(34)
' Decleare Filesystem Object
Dim fso
Set fso = CreateObject("scripting.filesystemobject")
' Decleare model name and check for existance
datFile = WScript.Arguments.Item(0)
If fso.FileExists(datFile) Then
modelBase = fso.GetBaseName(datFile)
modelInput = modelBase & ".bpn"
modelResult = modelBase & ".pns"
WScript.Echo modelInput
End If
' ****************************************************************'
' **** Read Pump speed and stages from all wells******************'
WScript.Echo "1"
' Declare Network Model Object
Set netModel = CreateObject("NET32COM.INETMODEL")
WScript.Echo "2"
' Tell that pipesim model is opening (disable when running Pipe-It)
WScript.Echo "Loading Pipesim model : " & modelInput & ". This might take some time..."
WScript.Echo "PIPESIM messeges follow:"
WScript.Echo ""
WScript.Echo "************************"
' Load model into Object
netModel.OpenModel(modelInput)
WScript.Echo "Starting run of Pipesim model " & modelInput
netModel.RunNetwork2 false, "-B"
bRunning = netModel.GetIsModelRunning
Do While bRunning
bRunning = netModel.GetIsModelRunning
WScript.Sleep(1)
Loop
WScript.Echo "************************"
WScript.Echo ""
WScript.Echo "Finished running Pipesim model " & modelInput
netModel.SaveModel(modelInput)
'Get name and count of producing wells
Dim count
Dim objname
Dim intobjname
count = 1
netModel.OpenModel modelInput
netModel.GetNameList 7, objname, count
For indx = 1 To count
WScript.Echo objname(indx-1)
Next
Any idea of what makes it fail at netModel.GetNameList ?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|