MapInfo Pro Developers User Group

Welcome to the MapInfo Pro Developers community!  We are a group dedicated to the discussion and understanding of MapBasic and .Net MapInfoPro AddIn development. Bring your questions and ideas here. This group includes several members of the Pro development team from around the world.

Please feel free to start a discussion in the discussion tab or join in a conversation.

Product Information  Ideas Portal  MapInfo Community Downloads

Discussions

Members

Resources

Events

 View Only
  • 1.  Delete All Columns After Specific Column

    Posted 03-19-2024 15:07

    Is there a way to delete all columns in a table after a specified column name?  I have a table named Locations and want to delete every column that exists after a column named Lead_lengt.

    Another way to consider it is Lead_lengt is column #162, is there a way to delete all after that column #?



    ------------------------------
    Jim
    ------------------------------


  • 2.  RE: Delete All Columns After Specific Column

    Posted 03-20-2024 02:27

    As a small mapbasic application, it could look like this:

    dim s as string
    dim i as integer
    dim N as integer
     
    s = "alter table xxx (drop "
    N = tableinfo(xxx,TAB_INFO_NCOLS)
     
    for i = 163 to N
      s = s+columninfo(xxx,"COL"+str$(i),COL_INFO_NAME)
      if i=N then 
        s = s+")"
      else
        s = s+","
      end if
    next
     
    run command s

    xxx is the tablename.



    ------------------------------
    Uffe Kousgaard
    CEO
    ROUTEWARE
    Roskilde
    ------------------------------



  • 3.  RE: Delete All Columns After Specific Column

    Posted 03-20-2024 10:26

    Thanks, Uffe.  That does exactly what I needed it to do.  I envy the programming skills that some of you guys have!



    ------------------------------
    Jim
    ------------------------------