Log In    |    Knowledge Base    |    4D Home
Tech Tip: Programmatically creating a hierarchical list
PRODUCT: 4D | VERSION: 2004.2 | PLATFORM: Mac & Win
Published On: December 13, 2005

Below is a piece of code that shows you how to programmatically create a hierachical list and save it so it will show in the List Editor of the Design environment.

ALL RECORDS([Table 1])


MyList:=Request("Enter a list name") `Ask for list name

$listNo:=New list ` create a list in memory

For ($i;1;Records in selection([Table 1]))

     APPEND TO LIST($listNo;[Table 1]Field1;Record number([Table 1]))

          `add records as elements to the list

     NEXT RECORD([Table 1])

End for

SAVE LIST($listNo;MyList) ` save the list.