MapInfo Pro Developers User Group

 View Only
  • 1.  Passing string array as Sub parameter from C#

    Posted 06-18-2020 04:04
    Hello, 

    I have already asked this question on MapInfo-L group, but I didn't get right answer. 

    Basically, I'm trying to pass array of strings to MBX Sub from C# assembly. 

    C# part of code:
    string[] subParams = { "param1", "param2"}
    mbxApp.CallMapBasicSubroutine("MySub", subParams);

    MabBasic sub:
    Declare Sub MySub(subParams() as String)
    
    Sub MySub(subParams() as String)  
    
      Print "Sub launched"
    
    End Sub

    Interestingly,  nothing happens when I run this code, you'll notice I haven't used any array member in Sub, just tried to print out message. No exception is caught both on C# and MB side. 

    Until now I have been passing single string (concatenated array members, delimited by semicolon), and then I would split them in Sub, however it would be nice to do it right way.

    ------------------------------
    Marijan
    ------------------------------


  • 2.  RE: Passing string array as Sub parameter from C#

    Employee
    Posted 06-24-2020 06:59
    Hi Marijan,
    We don't support passing array from C# to MapBasic sub. Passing single string (concatenated array members, delimited by semicolon), and then I would split them in Sub is the only way right now.

    ------------------------------
    Anshul Goel
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------



  • 3.  RE: Passing string array as Sub parameter from C#

    Posted 06-24-2020 07:40
    Anshul, 

    I was confused by method signature. Both in VS and ExtensibilityReferenceHelp is offered as string array. 

    Thank you for your answer

    ------------------------------
    Marijan
    ------------------------------



  • 4.  RE: Passing string array as Sub parameter from C#

    Employee
    Posted 06-24-2020 07:55
    Hi Marijan,
    Second parameter in CallMapBasicSubroutine is an array which notifies the number of parameter to the mapbasic sub.

    ------------------------------
    Anshul Goel
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------