define myrec record a int, b int, c charend record call myfunc(base.typeinfo.create(myrec)).. function myfunc(p)define p om.Domnode-- Do something end function
define myrec record a int, b int, c charend record call myfunc(base.typeinfo.create(myrec)) RETURNING myrec.*.. function myfunc(p)define p om.Domnode-- Do something RETURN p.SerializeToVariables()end function
ON ACTION save_field_values CALL save_field_values() ON ACTION get_field_values() CALL get_field_values()
LET l_root = ui.Interface.getRootNode()LET l_xpath = "//Dialog[@active=\"1\"]"LET l_dialog_list = l_root.selectByPath(l_xpath)FOR i = 1 To l_dialog_list.getlength() LET l_dialog_node = l_dialog_list.item(i) LET l_xpath = "//FieldInfo" LET l_fieldinfo_list = l_dialog_node.selectByPath(l_xpath) FOR j = 1 TO l_fieldinfo_list.getLength() LET l_fieldinfo_node = l_fieldinfo_list.item(j) LET l_nodeIdRef = l_fieldinfo_node.getAttribute("nodeIdRef") LET l_field_node = get_node_by_id(l_nodeIdRef) LET l_name = l_field_node.getAttribute("name") LET l_value = l_field_node.getAttribute("value") CALL add_to_list(l_name, l_value) END FOREND FOR
LET l_root = ui.Interface.getRootNode()LET l_xpath = "//Dialog[@active=\"1\"]"LET l_dialog_list = l_root.selectByPath(l_xpath)FOR i = 1 To l_dialog_list.getlength() LET l_dialog_node = l_dialog_list.item(i) LET l_xpath = "//FieldInfo" LET l_fieldinfo_list = l_dialog_node.selectByPath(l_xpath) FOR j = 1 TO l_fieldinfo_list.getLength() LET l_fieldinfo_node = l_fieldinfo_list.item(j) LET l_nodeIdRef = l_fieldinfo_node.getAttribute("nodeIdRef") LET l_field_node = get_node_by_id(l_nodeIdRef) LET l_value = read_from_list(l_name) CALL l_field_node.setAttribute(“name”, l_value) END FOREND FORCALL ui.Interface.XXX()
CALL xml.Serializer.DomToVariable(dom, function_to_return_a_variable())
IMPORT xml # this would probably be in an include file with r,c named more uniquelyDEFINE r,c xml.DomNode&define CALL_save_variable_to_dom(variable, dom) LET dom = xml.DomDocument.createDocument(#variable) \ LET r = dom.getDocumentElement() \ CALL xml.Serializer.variabletodom(variable, r) &define CALL_restore_dom_to_variable(dom, variable) LET r = dom.getDocumentElement() \ LET c = r.getLastChild() \ CALL xml.Serializer.domtovariable(c, variable) DEFINE mydomdoc xml.DomDocumentDEFINE myrec RECORD a INTEGER, arr DYNAMIC ARRAY OF RECORD x, y INTEGER END RECORDEND RECORD MAIN # Populate the record LET myrec.a = 1 LET myrec.arr[1].x = 2 LET myrec.arr[1].y = 3 LET myrec.arr[2].x = 4 LET myrec.arr[2].y = 5 CALL display_myrec("Initial values") # Save it away CALL_save_variable_to_dom(myrec, mydomdoc) # Clear out the variable INITIALIZE myrec.* TO NULL CALL myrec.arr.clear() # verify that the record is cleared CALL display_myrec("Record has been cleared") # Get it back CALL_restore_dom_to_variable(mydomdoc, myrec) # verify that the record has been restored CALL display_myrec("Record has been restored")END MAIN FUNCTION display_myrec(title)DEFINE title STRING &define show(p1) DISPLAY #p1 || " = ", p1 DISPLAY title show(myrec.a) show(myrec.arr.getlength()) IF myrec.arr.getLength() > 0 THEN show(myrec.arr[2].y) END IF DISPLAY ""END FUNCTION