#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    27
    Rep Power
    0

    Question 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.

    Devhims
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    6
    Rep Power
    0

    Py funcs from VB


    DevHims,

    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


    Sub Main()
    Py_Initialize

    bInit = Py_IsInitialized

    res = PyGetVersion

    Py_Finalize
    End Sub


    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.

    Dorel

    Comments on this post

    • Yegg` agrees
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    27
    Rep Power
    0

    Thumbs up


    Hey Dorel,

    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.

    DevHims
  6. #4
  7. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    101
    Rep Power
    0
    Originally Posted by DevHims
    Hey Dorel,

    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.

    DevHims
    Any progess on this, guys? I am so stuck!
  8. #5
  9. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    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.

IMN logo majestic logo threadwatch logo seochat tools logo