MapInfo Pro Developers User Group

Expand all | Collapse all

Can MapBasic please have a atn2 function? Excel has this function, and I think it would be useful in MapBasic to calculate the direction of a line segment.

  • 1.  Can MapBasic please have a atn2 function? Excel has this function, and I think it would be useful in MapBasic to calculate the direction of a line segment.

    Posted 07-18-2018 00:15


  • 2.  RE: Can MapBasic please have a atn2 function? Excel has this function, and I think it would be useful in MapBasic to calculate the direction of a line segment.

    Pitney Bowes
    Posted 07-30-2018 20:46

    Hi Nick,

    I agree there are quite a few functions we should add to mapbasic. And we should. But here is a workaround coming out in version v17.01 that will let you add it yourself:

    Below is the release notes for 2 new methods added to our object model that can be called from a mapbasic application to add new mapbasic functions that can be called by Pro users. You could always use custom functions in sql and update statements from a mapbasic app, but now you can let end users or applications call your own custom functions from Pro in select & update statements, label expressions and more. Of course your addin will need to be loaded for these to work but it could solve your issue. V17.01 is undergoing final testing and should be out by early September (I am a developer not in sales or marketing, so I can say forward looking statements). Anyway let me know if you think this could solve your problem.

     

    -Bob

    New methods RegisterPublicFunction and UnregisterPublicFunction on IMapBasicApplication

    Add the ability for a Pro addin to expose mapbasic functions for use by the end-user

    The functions show up in the “Assist” and “Expression” Dialogs

    They can be used anywhere where mapbasic expressions are used

    Select statements

    Update statements

    Label Expressions

    Theme expressions

    Smart Text

     etc

     

    /// Registers a mapbasic function so that it is shown in the UI and can be called from interpreted code

    /// </summary>

    /// <param name="functionName">name of function inside mbx</param>

    /// <param name="publicName">public name for function, can be different than functionName</param>

    /// <param name="description"></param>

    /// <returns>ID number of function. Use this id to unregister the function.</returns>

    /// <remarks>When the addin is unloaded any registered public functions from the addin are automatically unregistered.</remarks>

    int RegisterPublicFunction(string functionName, string publicName, string description);

    MapBasic:

    IMBXRegisterPublicFunction (ByVal IMBXInstance As This, ByVal functionName As String, ByVal publicName as String, ByVal description as String) As Integer

     

    /// <summary>

    /// Unregisters a mapbasic function from the UI

    /// </summary>

    /// <param name="fcnid">Id of function to unregister. If value is -1, all functions registered for this mbx are unregistered.</param>

    void UnregisterPublicFunction(int fcnid);

    MapBasic:

    IMBXUnregisterPublicFunction (ByVal IMBXInstance As This, ByVal fcnid As Integer)

    ?