MapInfo Pro

 View Only
  • 1.  Prompting the user to choose a table and then choose a column from the chosen table

    Posted 10-04-2022 09:32
    Edited by Peter Møller 10-05-2022 01:13
    Sorry, I just can't figure this one out - it seems such a simple thing but I'm getting nowhere. 

    I am writing a program that begins by prompting the user to choose a table from those that are open and I have restricted the options by dominant object type (the table should always be point geometry). Easy enough. 

    Next I want to prompt the user to choose from a list of existing columns that exist within the previously chosen table. No luck. 

    I can produce a list of ALL columns from ALL open tables (unhelpful). I can produce a list of columns from ONE specific table by name. But I cannot produce a list of columns from ONE table that happens to be a variable. Here's my test code:

    Dim Tabz as Alias
    Dim Colz as String

    Tabz = input(
    "Table", 'Window title
    "_Table:", 'Prompt
    "", 'Default value
    "table", 'Type of input
    "", 'Help text
    "TableInfo(ScriptContext(2),TAB_INFO_DOMINANT_OBJECT_TYPE)=2" 'choice limitations
    )

    Colz = input(
    "Column",
    "_Column:",
    "",
    "column",
    "",
    "TableInfo(Scriptcontext(2), TAB_INFO_NAME)=Tabz"
    )

    Thanks in advance for any help that can be offered and apologies if I am missing something daft.

    Ryan

    ------------------------------
    Ryan Cook
    Knowledge Community Shared Account
    ------------------------------


  • 2.  RE: Prompting the user to choose a table and then choose a column from the chosen table

    Employee
    Posted 10-05-2022 01:13
    Hi Ryan

    The problem lies in the way you pass in the table to use but I'm sure you were already aware of this.
    Your approach makes MapInfo Pro look for a table called "Tabz".

    Change the last parameter to:
    "TableInfo(Scriptcontext(2), TAB_INFO_NAME)=" + Tabz

    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------



  • 3.  RE: Prompting the user to choose a table and then choose a column from the chosen table

    Posted 10-05-2022 04:32
    Ha, I knew it would be something simple! I was suffering from a brain block - I tried double quotes, triple quotes, square brackets, apostrophes... I just couldn't figure out how to get Mapinfo to understand that Tabz was a variable! 

    Thanks Peter, that's the second time you have rescued me.

    ------------------------------
    Ryan Cook
    Knowledge Community Shared Account
    ------------------------------