Hi!
So I'm trying to move our vba scripts from old v8i to Connect edition. Most of the things work just fine but when I'm trying to run a script which is using
Private Declare PtrSafe Sub mdlDialog_completionBarUpdate Lib "stdmdlbltin.dll" (ByVal dbP As Long, ByVal msgText As String, ByVal percentComplete As Long)Private Declare PtrSafe Function mdlDialog_completionBarOpen Lib "stdmdlbltin.dll"(ByVal messageText As String) As LongPrivate Declare PtrSafe Sub mdlDialog_completionBarClose Lib "stdmdlbltin.dll" (ByVal dbP As Long)
Microstation gives me an error telling me that it didnt find an entrypoint for mdlDialog_completionBarOpen in stdmdlbltin.dll .
mdlDialog_completionBarOpen
stdmdlbltin.dll
Usually I would have looked into the mdl documentation and would hopefully find some Declare statements at the bottom of the page telling me that there is another lib or that I have used wrong types. But I couldn't find the mdl docs (which makes sense as mdl is gone, right?).
Inside the MicrostationAPI documentation I found the function so I know it still exists. So my question is: which Lib should I use for Declare in VBA? Or better: how would I be able to look that up by myself? Or if it is just the wrong types: how could I look up the argument and return types that VBA Declare is expecting for each function?
As always I would be really glad if someone could help me with that stuff.
RegardsStephan
Hi Stephan,
Unknown said:But I couldn't find the mdl docs (which makes sense as mdl is gone, right?).
Well, it's questionable what "MDL" means today ;-) What is gone is old pseudocode support (which is MDL in it's original meaning) and also native C API (which is what MDL evolved to in V8 generation). But today MDL is more like "any language and API that can be used to develop applications or addins for MicroStation".
Unknown said:Usually I would have looked into the mdl documentation and would hopefully find some Declare statements at the bottom of the page
Unfortunately this part of documentation was lost and description how methods are exported is not available. Usin MicroStatioAPI documentation and some tools it can be reconstructed, but it requires extra effort.
Unknown said:Inside the MicrostationAPI documentation I found the function so I know it still exists.
Both yes and no. Yes, because the most of C functions were migrated to C++ API as static methods and are exported, so they are still accessible, even though often with changed signatures because of migration from 32 to 64bits. But small "no", because not all C functions were migrated and are available in CE API.
Unknown said:how would I be able to look that up by myself?
You can use tools like dumpbin.exe (part of VIsual Studio tools) or DLL Export Viewer from Nirsoft to list functions exported in a particular dll files. Because how functions are exported is fixed (I guess C calling convetion is used so VBA code is able to access the functions), when C++ description is available, it's usually possible to asses how VBA declaration should look like.
I guess the most of functions are still in the same dll files as they were in V8i, so the main file is still stdmdlbltin.dll.
Yes, but the problem with specifically mdlDialog_completionBarOpen function is that it exists in C++ API, but it seems it's not exported (available) in stdmdlbltin.dll. Consequently it cannot be called from any external code including VBA. Because the function is described in MicroStationAPI help file and some other mdlDialog_ functions are exported, I assume it's an omission and should be reported as bug.
But for now, I guess there is no solution how to use this function from VBA code.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Answer Verified By: Stephan L.
Hi Jan,
thank you very much for your detailed reply. Things are getting a little bit clearer now.
I have taken a look into vba documentation and found a page about changes that arise with 32- / 64-Bit conversion...LongPtr LongLong and stuff. It is inside Microstations VBA documentation and is pretty extensive.
I will give the dumpbin.exe a try as I have Visual Studio installed.
It seems like an unfortuante coincidence to stumble over a not-exported function while "fighting" error messages due to insufficient 64-bit adaption of my code...well, now I know better.