0

I try to get data from table use MapBasic:

Dim nCol = "ColumnName"
Fetch First From Untitled
Do While Not EOT(Untitled)
  colValue = Selection.nCol
Note colValue
Fetch Next From Untitled
Loop

Compilation ends success but when i start application in MapInfo get error:

Not defined Selection.nCol

How to work with columns in this case?

2

I believe you need to use an alias, something like this (untested)

Dim nCol as alias
Fetch First From Untitled
Do While Not EOT(Untitled)
    nCol = Untitled + ".ColumnName"
    colValue = nCol
    Note colValue
    Fetch Next From Untitled
Loop
  • If your table name as well as your column are hard coded, you don't need an Alias variable, you can just refer to the combination of these two names: Untitled.ColumnName. If one of them is a variable, you need to go thru an Alias variable – Peter Horsbøll Møller Jul 29 '13 at 7:22
  • Also quick note that if you can't hardcode a column name, you can get columns dynamically by column number like .col2 or .col(2) – user568458 Oct 25 '13 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.