KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Storing a Hierarchical List in a Record
PRODUCT: 4D | VERSION: 6.5 | PLATFORM: Mac & Win
Published On: March 10, 2000
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Hierarchical lists are stored in the structure file. There are times when it is useful to store a Hierarchical list in the data file, especially when you want user modified lists to not change when updating to a new structure file. The code is easy to develop if you store the hierarchical lists as BLOBs in a record. Here is example code for storing a hierarchical list into a record and restoring the hierarchical list from a record.

Cut and Paste the following code example into your
own 4D project

` To save a list to a record
$list:="my_list" ` the name of the list
CREATE RECORD([Blobs])
$temp_list:=Load list($list)
[Blobs]BLOB_Name:=$list
LIST TO BLOB($temp_list;[Blobs]BLOB)
SAVE RECORD([Blobs])

` To restore a list from a record
$list:="my_list" ` the name of the list
QUERY([Blobs];[Blobs]BLOB_Name=$list)
BLOB to list([Blobs]BLOB;$temp_list)
SAVE LIST($temp_list;$list)