KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility method that returns the data source type of a List box
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: August 29, 2022

The following utility method returns the data source type of a List box object. The method works in both Binary and Project mode.

 // Method: listboxGetDataSourceType
 // Parameter: $1 - Listbox name

#DECLARE($listbox_t : Text)->$dataSourceType_t : Text

If (Count parameters>=1)

  var $tableNum_l : Integer
  var $namedSel_t : Text
  LISTBOX GET TABLE SOURCE(*; $listbox_t; $tableNum_l; $namedSel_t)

  If ($tableNum_l>0)
    If ($namedSel_t="")
      $dataSourceType_t:="Current Selection"
    Else
      $dataSourceType_t:="Named Selection"
    End if
  Else
    var $dataSource_p : Pointer
    $dataSource_p:=OBJECT Get pointer(Object named; $listbox_t)
    Case of
      : ($dataSource_p=Null)
      : (Type($dataSource_p->)=Is longint)
        $dataSourceType_t:="Entity Selection"
      : (Type($dataSource_p->)=Is collection)
        $dataSourceType_t:="Collection"
      : (Type($dataSource_p->)=Boolean array)
        $dataSourceType_t:="Array"
    End case
  End if
End if