Is it possible to use Mapbasic to return an array from a .NET dll and then assign the returned array to a Mapbasic array?
------- mapbasic code --------
Dim tmp_sharg_layer_list() as string
Declare Method getShargTypes Class "ShargUI.Functions" Lib "ShargUI.dll" As String SUB populate_sharg_list tmp_sharg_layer_list = getShargTypes END SUB
--------- c# code ---------
public static string[] getShargTypes()
{
DataTable dt = SectionDetailForm.PopulateDT("select name from ShargTypes order by TypeID"); // PopulateDT returns DataTable after connecting to an access mdb
string[] result = new string[dt.Rows.Count];
for (int i=0;i< dt.Rows.Count;i++)
{
result[i] = dt.Rows[i]["name"].ToString();
}
return result;
}
I keep getting the following error message for the MB code shown above “Cannot assign to array or type variable: tmp_sharg_layer_list” Basically I just want to use .NET to connect to my access database instead of using an attribute-only ODBC connection in Mapinfo. My existing code which works ok looks like this: ------------- existing mapbasic code SUB populate_sharg_listdim I as integerI = 1open table applicationdirectory$()+ "qry_DistinctType.tab" as qry_DistinctTypeServer Refresh qry_DistinctTypefetch first from qry_distinctTypeDo While Not EOT(qry_DistinctType)redim tmp_sharg_layer_list(I)tmp_sharg_layer_list(I) = qry_DistinctType.typefetch next from qry_DistinctTypeI = I+1Loop
END SUB
Any advice would be gratefully received Regards, Matt
Matt Hodgskiss BSc Msc
GIS Officer
Survey, Cartography & GIS
Engineering Consultancy Services
103 Wellington Road South
Stockport
SK1 3TT
Tel:0161 474 4913
Web: http://www.stockport.gov.uk/ecs
Email:matthew....@stockport.gov.uk
Is it possible to use Mapbasic to return an array from a .NET dll and then assign the returned array to a Mapbasic array?