June 21st, 2004, 11:17 AM
Run Python Script from VB?
Hii to all,
How to u initialize python interpreter uisng function py_Initialize() from VB?
Once you initilaize python Interpreter using py_Initialize() function, can u run python script using py_SimpleFile() function?
everything is welcome.
June 21st, 2004, 11:52 AM
Py funcs from VB
here's the code that I run from VB and id definitely communicates with Python:
Public Declare Function Py_Initialize Lib "python23" () As Long
Public Declare Function Py_IsInitialized Lib "python23" () As Long
Public Declare Function Py_Finalize Lib "python23" () As Long
Public Declare Function Py_GetPath Lib "python23" () As Long
Public Declare Function Py_GetVersion Lib "python23" () As Long
Public Declare Function PyRun_SimpleString Lib "python23" (ByRef command As String) As Long
bInit = Py_IsInitialized
res = PyGetVersion
Because of data format conflict I cannot use PyRun_SimpleString. There is need to figure out how to convert strings into data types that are being accepted by functions in python23.dll (23 is the version number). For now I declare these functions to take in and return Long type variables. When I get some free time I will try to figure out how to pass in and out pointers from VB to python's dll without crashing.
Comments on this post
June 21st, 2004, 04:09 PM
Thanks man. I will also try to find way to execute python script using "PyRun_SimpleFile()" or PyRun_AnyFile()". If i will get it i will let u know.
August 28th, 2005, 10:37 PM
Any progess on this, guys? I am so stuck!
Originally Posted by DevHims
August 29th, 2005, 08:40 AM
There's nothing to be stuck about. Visual Basic 6 will allow you to call any function from the Python DLL file. In this case we are dealing with Python 2.3, so the DLL file is python23.dll. If this was Python 2.4, the DLL file would be python24.dll.