This utility provides a dialog that allows you to view and edit DXL attributes in the current module. This is a much easier and faster way to edit DXL attributes than having to use the normal edit attributes dialog.
This is also useful if you are just looking to see what DXL attributes are defined in the current module without the need to check each attribute individually.
// editDxlAttributes /* Edit DXL Attributes Provides a dialog for editing DXL Attributes. Tony Goodman */ pragma runLim,0 DB db = null DBE dbeDxl = null DBE dbeAttrs = null DBE dbeFrame = null DBE btnUpdate = null DBE btnCheck = null string dummy[] = { } Skip skipAttributes = createString Module currModule = current Module string selectedAttributeName = "" AttrDef selectedAttribute = null bool readOnly = false string dxlString = "" /***************** getDxl *******************/ void getDxl() { dxlString = selectedAttribute.dxl set(dbeDxl, dxlString) } /*********************** setDxl ***********************/ void setDxl() { selectedAttribute = modify(selectedAttribute, setDXL, get(dbeDxl)) } /******************************* getAttributes *************************/ void getAttributes() { AttrDef ad = null string attr = "" int index = 0 for ad in currModule do { if (ad.system) continue if (!ad.dxl) continue put(skipAttributes, ad.name, ad.name) } for attr in skipAttributes do { insert(dbeAttrs, index, attr, iconNone) index++ } set(dbeAttrs, 0, true) } /************************* doSelect ************************/ void doSelect(DBE dbe, int i) { selectedAttributeName = get(dbeAttrs) selectedAttribute = find(currModule, selectedAttributeName) getDxl() } /************************* doActivate ***************************/ void doActivate(DBE dbe, int i) { ; } /************************ doDeselect ******************************/ void doDeselect(DBE dbe, int i) { ; } /************************* checkDxl **********************/ bool checkDxl() { string err = "" err = checkDXL(get(dbeDxl)) if (err "" == "") { return(true) } print(err) //warningBox("There were errors - see DXL interaction window") return(false) } /***************** doCheck *********************/ void doCheck(DB db) { if (checkDxl()) { infoBox("No errors") } else { warningBox("There were errors - see DXL interaction window") } } /****************** doUpdate *******************/ void doUpdate(DB db) { if (confirm("You are about to update the DXL code for this attribute\n" //- "Are you sure you want to continue?")) { if (checkDxl()) { setDxl() infoBox("Attribute updated") } else { warningBox("Attribute DXL was not updated. There were errors - see DXL interaction window") } } } /*************** buildDialog ******************/ void buildDialog() { db = create(current Module, "Edit DXL Attributes") dbeFrame = frame(db, "", 800, 500) dbeFrame->"top"->"form" dbeFrame->"left"->"form" dbeFrame->"right"->"form" dbeFrame->"bottom"->"form" dbeAttrs = listView(db, 0, 170, 10, dummy) dbeAttrs->"top"->"inside"->dbeFrame dbeAttrs->"left"->"inside"->dbeFrame dbeAttrs->"right"->"unattached" dbeAttrs->"bottom"->"inside"->dbeFrame dbeDxl = text(db, "DXL Code", "", 630, 150, false) dbeDxl->"top"->"inside"->dbeFrame dbeDxl->"left"->"flush"->dbeAttrs dbeDxl->"right"->"inside"->dbeFrame dbeDxl->"bottom"->"inside"->dbeFrame btnCheck = apply(db,"Check", doCheck) btnUpdate = apply(db,"Update", doUpdate) realize(db) if (readOnly) { inactive(btnUpdate) } set(dbeAttrs, doSelect, doDeselect, doActivate) insertColumn(dbeAttrs, 0, "DXL Attributes", 160, iconNone) getAttributes() block(db) destroy(db) db = null } /**************** editDxlAttributes ***************/ void editDxlAttributes() { currModule = current Module if (null currModule) { infoBox("This utility can only be run from a formal module") halt } if (!isEdit currModule) { readOnly = true } buildDialog() } editDxlAttributes()