Get List Column Number


#1

Looking for a function to return the column number of a LIST given the column “name”.
Something like GetColumnNumber(‘MyColumnField’)

Haven’t yet found anything in the docs or by searching the class files.


#2

Ok, I will have a try :slight_smile:

LOOP
  i += 1
  IF ?List{PROPLIST:Exists, i} = FALSE
    BREAK
  END
  IF InString(columnNameYouAreLookingFor, ?List{PROPLIST:Header, i}, 1, 1) > 0
    ! Maybe this is the column you are looking for?
    RETURN i
  END
END

Note: This probably needs tweaking for group columns and other things.

Also, do a search in \LibSrc for PROPLIST:Exists to get some other ideas. For example BrowseClass.UpdateQuery in ABBROWSE.CLW:

BrowseClass.UpdateQuery PROCEDURE(QueryClass QC, BYTE Caseless)
I       USHORT(1)
FN      CSTRING(100)
Found   BYTE
Field   UNSIGNED(1)
F       &File
  CODE
  ASSERT(SELF.Query &= NULL)
  SELF.Query &= QC
  LOOP WHILE SELF.ILC.GetControl(){PROPLIST:Exists,I}
    FN = SELF.ListQueue.Who(SELF.ILC.GetControl(){PROPLIST:FieldNo,I})
    IF FN
       Found = False
       LOOP Field = 1 to SELF.View{PROP:Fields}
            F &= SELF.View{PROP:FieldsFile, Field}
            IF F{PROP:Label, SELF.View{PROP:Field, Field}}=FN
               Found = True
               BREAK
            END
       END
       IF Found
          IF CaseLess
             FN = 'UPPER(' & FN & ')'
          END
          QC.AddItem(FN,SELF.ILC.GetControl(){PROPLIST:header,I},SELF.ILC.GetControl(){PROPLIST:picture,I})
       END
    END
    I += 1
  END