Purpose
Returns information about a column in an open table. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
ColumnInfo( { tablename | tablenum } ,
{ columnname | "COLn" } , attribute )
tablename is a string representing the name of an open table.
tablenum is an integer representing the number of an open table.
columnname is the name of a column in that table.
n is the number of a column in the table.
attribute is a code indicating which aspect of the column to read.
Return Value
Depends on the attribute parameter specified.
Description
The ColumnInfo() function returns information about one column in an open table.
The function's first parameter specifies either the name or the number of an open table. The second parameter specifies which column to query. The attribute parameter dictates which of the column's attributes the function should return. The attribute parameter can be any value from this table.
attribute setting | ID | ColumnInfo() returns: |
---|---|---|
COL_INFO_NAME | 1 | String identifying the column name. |
COL_INFO_NUM | 2 | SmallInt indicating the number of the column. |
COL_INFO_TYPE | 3 | SmallInt indicating the column type (see table below). |
COL_INFO_WIDTH | 4 | SmallInt indicating the column width; applies to Character or Decimal columns only. |
COL_INFO_DECPLACES | 5 | SmallInt indicating the number of decimal places in a Decimal column. |
COL_INFO_INDEXED | 6 | Logical value indicating if column is indexed. |
COL_INFO_EDITABLE | 7 | Logical value indicating if column is editable. |
If the ColumnInfo() function call specifies COL_INFO_TYPE as its attribute parameter, MapBasic returns one of the values from the table below:
ColumnInfo() returns: | ID | Type of column indicated: |
---|---|---|
COL_TYPE_CHAR | 1 | Character. |
COL_TYPE_DECIMAL | 2 | Fixed-point decimal. |
COL_TYPE_INTEGER | 3 | Integer (4-byte). |
COL_TYPE_SMALLINT | 4 | Small integer (2-byte). |
COL_TYPE_DATE | 5 | Date. |
COL_TYPE_LOGICAL | 6 | Logical (TRUE or FALSE). |
COL_TYPE_FLOAT | 8 | Floating-point decimal. |
COL_TYPE_TIME | 37 | Time. |
COL_TYPE_DATETIME | 38 | DateTime. |
COL_TYPE_LARGEINT | 39 | Large integer. |
The codes listed in both of the above tables are defined in the standard MapBasic definitions file, MAPBASIC.DEF. Your program must include "MAPBASIC.DEF" if you intend to reference these codes.
Error Conditions
ERR_TABLE_NOT_FOUND (405) error generated if the specified table is not available.
ERR_FCN_ARG_RANGE (644) error generated if an argument is outside of the valid range.
Example
Include "MAPBASIC.DEF"
Dim s_col_name As String, i_col_type As SmallInt
Open Table "world"
s_col_name = ColumnInfo("world","col1",COL_INFO_NAME)
i_col_type = ColumnInfo("world","col1",COL_INFO_TYPE)
See Also: