Message
Hi
everyone, still a strange phenomen....
Does
the ColumnInfo statment affect the current cursor position in a table ?
Look
at the following sample, written in VB.NET :
========================================================================================
Public Sub Test(ByVal nom_layer As String)
Dim msg As String
Dim nom_col As String
Dim dt As DataTable
Dim nb_cols As Short
Dim i As Short
Dim type_col As Short
Dim col_type As System.Type
Dim nb_rows As Integer
Dim j As Integer
Dim log_val As String
Dim rowid As Integer ' **************FOR FIXING
BUG***********
Dim jj As Integer
Try
msg = "TableInfo(" + nom_layer + "," + TAB_INFO_NROWS.ToString + ")"
jj = mapinfo.eval(msg)
Console.WriteLine("nb rows into " + nom_layer + " : " +
jj.ToString)
mapinfo.Do("Fetch First From " + nom_layer)
jj = 0
While (mapinfo.Eval("EOT(" + nom_layer + ")") = "F")
mapinfo.Do("Fetch Next From " + nom_layer)
jj += 1
End While
Console.WriteLine("nb rows processed at EOT : " +
jj.ToString)
msg = "TableInfo(" + nom_layer + "," + TAB_INFO_NCOLS.ToString + ")"
nb_cols = mapinfo.eval(msg)
dt = New DataTable(nom_layer)
For i = 1 To nb_cols
msg = "ColumnInfo(" + nom_layer + "," + """" + "COL" +
i.ToString + """" + "," _
+ COL_INFO_NAME.ToString + ")"
nom_col = mapinfo.eval(msg)
msg = "ColumnInfo(" + nom_layer + "," + """" + nom_col + """" + "," _
+ COL_INFO_TYPE.ToString + ")"
type_col = mapinfo.eval(msg)
Select Case type_col
Case COL_TYPE_CHAR
col_type = System.Type.GetType("System.String")
Case COL_TYPE_DECIMAL
col_type = System.Type.GetType("System.Decimal")
Case COL_TYPE_INTEGER
col_type = System.Type.GetType("System.Int32")
Case COL_TYPE_SMALLINT
col_type = System.Type.GetType("System.Int16")
Case COL_TYPE_DATE
col_type =
System.Type.GetType("System.DateTime")
Case COL_TYPE_LOGICAL
col_type = System.Type.GetType("System.Boolean")
Case COL_TYPE_FLOAT
col_type = System.Type.GetType("System.Double")
Case COL_TYPE_GRAPHIC ' special column 'Obj' :
nothing to do
GoTo next_column
Case Else ' unknown type
MessageBox.Show("Table " + nom_layer _
+ " : impossible de déterminer le type de
la colonne '" + nom_col + "'.", _
"Erreur", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Select
dt.Columns.Add(nom_col, col_type)
next_column:
Next
mapinfo.Do("Fetch First From " + nom_layer)
jj = 0
While (mapinfo.Eval("EOT(" + nom_layer + ")") = "F")
'rowid = mapinfo.eval(nom_layer + ".RowId")
' **************FOR FIXING BUG***********
For i = 1 To nb_cols
msg = "ColumnInfo(" + nom_layer + "," + """" +
"COL" + i.ToString + """" + "," _
+ COL_INFO_TYPE.ToString + ")"
type_col = mapinfo.eval(msg)
Next
'mapinfo.do("Fetch Rec " + rowid.ToString + " From " +
nom_layer) ' **************FOR FIXING BUG***********
mapinfo.Do("Fetch Next From " + nom_layer)
jj += 1
End While
dt.AcceptChanges()
Console.WriteLine("table:" + dt.Rows.Count.ToString)
Catch ex As Exception
Fonctions_diverses.DisplayException(ex)
End Try
End Sub
========================================================================================
The output is :
nb rows into Monde7 : 252 ==> OK
nb rows processed at EOT : 252 ==> OK
table:133 (for example, or 365, or 411,
etc....) ==> should be 252 !
========================================================================================
ColumnInfo statment, with COL_INFO_TYPE
paramater, seems to affect current cursor position into the Monde7
table (world7 in english)
sometimes forward, sometimes backward, and
by this way, due to the 'While (mapinfo.Eval("EOT(" + nom_layer + ")")
= "F")' _expression_, the number of lines processed is greater or lower
than the true value, who is 252 !
To fix that, I had to add the two lines
marked with **************FOR FIXING BUG*********** in the code.
Any idea ?
Thank you - Chris
_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l