Dynamic enumeration values can be achieved by extending the base types of attribute domain with a script-based solution. Please find below an implementaiton example for such a solution where the possible values for an attribute are read from a file residing within the ADOxx database, but potentially also anywhere on the file system, written during initialisation, or on a file share.
Select from list and store in STRING attribute 1# 1. Store information of current object
2SET nCurrentObjID: (objid)
3# 2. Read enumeration list from file
4CC "AdoScript" FREAD file: ("db:\\carTypes.txt")
5SET sEnumerationValues: (text)
6# 3. Open List and pre-select
7CC "Core" GET_ATTR_VAL objid: (nCurrentObjID) attrname:"Type"
8SET sCurrentSelection: (val)
9CC "AdoScript" LISTBOX entries: (sEnumerationValues) toksep:";" title:"Select car type" oktext:"Apply" boxtext:"Choose car type:" selection: (sCurrentSelection)
10IF (endbutton = "ok")
11{
12 CC "Core" SET_ATTR_VAL objid: (nCurrentObjID) attrname:"Type" val: (selection)
13}
It is also possible to have the update of the list included in the tool, see the following snipplet as a reference how to handle add and remove functions via the menu
Add enumeration value: 1# 1. Read enumeration list from file
2CC "AdoScript" FREAD file: ("db:\\carTypes.txt")
3SET sEnumerationValues: (text)
4# 2. Display editfield
5CC "AdoScript" EDITFIELD title:"Enter new car type" caption:"Car type:"
6IF (ecode = 0)
7{
8 # 3. store the result of tokunion -> dublicates are excluded and ignored
9 CC "AdoScript" FWRITE file: ("db:\\carTypes.txt") text: (tokunion(sEnumerationValues, text, ";"))
10}
Remove values from enumeration list (does not check for used values in models, could be done using AQL) 1# 1. Read enumeration list from file
2CC "AdoScript" FREAD file: ("db:\\carTypes.txt")
3SET sEnumerationValues: (text)
4# 2. Display in multiselect box
5CC "AdoScript" MLISTBOX entries: (sEnumerationValues) toksep:";" title:"Select car type" oktext:"Apply" boxtext:"Choose car type:" selection: (sCurrentSelection)
6IF (endbutton = "ok")
7{
8 # 3. save the diff between the initial set and those selected for removal
9 CC "AdoScript" FWRITE file: ("db:\\carTypes.txt") text: (tokdiff(sEnumerationValues, selection, ";"))
10}
The integration implementation is available in the attached ABL file.
WebService SolutionA more complex solution is available in the following thread:
http://www.adoxx.org/live/faq/-/message_boards/message/87053. This implementation reads from a web-service to retrieve the enumeration values.