KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Selection To List
PRODUCT: 4D | VERSION: 15.x | PLATFORM: Mac & Win
Published On: May 10, 2017

Below is an utility method to return the current selection of a table's field to a list.

// Method: SELECTION_TO_LIST
// $1 - Field Pointer
// $0 - List reference

C_POINTER($fieldPtr;$1;$tablePtr)
C_LONGINT($listRef;$itemRef)

If (Count parameters>=1)
  $fieldPtr:=$1
  $listRef:=New list

  $tablePtr:=Table(Table($fieldPtr))
  While (Not(End selection($tablePtr->))
     APPEND TO LIST($listRef;$fieldPtr->;$itemRef)
     NEXT RECORD($tablePtr->)
  End while
  $0:=$listRef
End if


Example of usage:
ALL RECORDS([Table_1])
$listRef:=SELECTION_TO_LIST (->[Table_1]Field_2)
SAVE LIST($listRef;"Table 1 List")