Question

First time question asker - I have searched through the site for questions related to VBSCRIPT, C++, and COM. I have found a couple of threads that I do believe speak to my core question but I was not able to walk away with an absolute.

I have been tasked with writing an automation script for a trucking company that uses PCMIler (which is arguably the most pervasive commercial trip routing tool in the market). The product comes with a tool called PCMiler Connect. PCmiler connect offers various API's to query the database. One of those is COM.

PCMiler is written in C++. I'm trying to accomplish this with VBScript.

The problem I'm having is trying to execute a method that requires 1 argument to be passed by reference. The method takes 4 arguments. It uses 3 of them to calculate the distance in miles from 2 points. The 4th argument is the one passed by reference and the retval is the 'time' in minutes.

Set server = CreateObject("PCMServer.PCMServer")
region = Server.DefaultRegion

Dim dist  'dist is short for Distance
Dim minutes
Dim time
'First Example  use standard CalcDistance  //THIS FUNCTION WORKS JUST FINE.
dist = server.CalcDistance("63139","62025")  'the passed parameters are Zip Codes
Wscript.Echo "CalcDistance: " & (dist / 10)   'Echo the distance in miles

//THIS EXAMPLE DOES NOT WORK!!!!
'Third Example  use CalcDistance3 with a Route Type of 'Practical' (which is the 3rd argument).      Pass variable 'minutes' as the return variable.
'Third Example - version 1.  Passing the variable 'minutes' by itself - no character to indicate it is being passed by reference.
dist = server.CalcDistance3("63139","37217",1,cLng(time))

I have read in some threads that C++ must return the retval as Variant. This function returns a Long Integer. I can't change this. When I read the log file for PCMiler connect I can see where the retval is being calculated and logged - but VBScript is not picking it up, or it is not being returned correctly?

Ultimately - I'd like to ask someone to tell me If I'm out of look for using VBScript due to the fact I can't alter the C++ method - or if I can find a way to get the value - please help. If not - can someone tell me a better option for what I need to do?

  1. While I have successfully used VBA in Access - this needs to be an automated script running every 30 minutes. I understand Access is not something that can be run reliably as an automated service.
  2. C#?
  3. VB?

Thank you.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top