MapInfo Pro Developers User Group

 View Only
  • 1.  How to pass a parameter from Python to a MapBasic procedure?

    Posted 09-19-2025 15:00
    Edited by Peter Møller 15 days ago

    Hi,

    If I can, how do I pass a parameter to the "FromPython" (the one from example) MapBasic subroutine or function from python side? 

    It didn't work when I tried this 

                     thisApplication.CallMapBasicSubroutine("FromPython", 1)    # as a sub
    or 
                      thisApplication.CallMapBasicSubroutine("FromPythonFunc", 1)    # changed to a function. 
    can someone please help? Thank you. 



    ------------------------------
    Ferhad Pakzat

    BRITISH COLUMBIA HYDRO AND POWER AUTHORITY
    Burnaby BC
    ------------------------------



  • 2.  RE: How to pass a parameter from Python to a MapBasic procedure?

    This message was posted by a user wishing to remain anonymous
    Posted 09-19-2025 17:31
    This post was removed


  • 3.  RE: How to pass a parameter from Python to a MapBasic procedure?

    Employee
    Posted 15 days ago
    Edited by Peter Møller 15 days ago

    I looked at the documentation for CallMapBasicSubroutine in the Extensibility Reference:

    void CallMapBasicSubroutine(
    	string methodName,
    	params string[] parameters
    )

    The parameters need to be passed to the subroutine as a string array.

    The docs state:

    Parameters
    methodName
      Type: SystemString
      name of the mapbasic subroutine to call
    parameters
      Type: SystemString
      Parameters to the subroutine. Parameters are passed by value to the subroutine; if the subroutine accepts no arguments, then pass null.

    However, after reading this post, I realized that we may not support you passing multiple parameters as an array. The workaround is to concatenate your parameters into a single string separated by semicolons, and then split them in the procedure.

    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------