Regarding 2.:
In order to make the solution in 1. work also outside the current model, some adaptations have to be made in the update.asc file (section 2)). You will find below the adapted code for the update.asc file and the code for the procedure used in update.asc.
In the procedure you use the GET_MODEL_GROUP_TREE_XML, which generates an XML string containing the current model group tree structure. Thus, this XML string also contains modelids of all models. In the next step you search for the <model> tags in the XML string and copy the value of the attribute id to a string called lModelIDs. The result is a list of all modelids. The adaptation in the update.asc file is, that you (FOR-) loop through the modelids list to get the objects of class A from all models. The result is a list of all objects of class A not just from the current model, but from all models.
2) update.asc:
1CC "Core" GET_CLASS_ID objid: (nInstId)
2#-->RESULT ecode:intValue classid:intValue
3SETL nClassID: (classid)
4
5CC "Core" GET_CLASS_NAME classid: (nClassID)
6#-->RESULT ecode:intValue classname:strValue isrel:intValue
7SETL sClassName: (classname)
8
9IF(sClassName = "A") {
10 CC "Core" GET_ATTR_NAME attrid: (nAttrId)
11 #-->RESULT ecode:intValue attrname:strValue
12 SETL sAttrName: (attrname)
13
14 IF(sAttrName = "a3") {
15 CC "Core" GET_ATTR_VAL objid: (nInstId) attrid: (nAttrId)
16 #-->RESULT ecode:intValue val:anyValue
17 SETL sAttrVal: (val)
18
19 SETL lObjids: ("")
20 GET_ALL_MODELIDS lModelIDs: ("") nStartingPointForSearch: (0 ) result:lModelIDs
21 FOR i from: (0) to: (tokcnt(lModelIDs)-1) {
22 CC "Core" LOAD_MODEL modelid: (VAL (token(lModelIDs,i)))
23 #-->RESULT ecode:intValue isloaded:intValue
24 CC "Core" GET_ALL_OBJS_OF_CLASSNAME modelid: (VAL(token(lModelIDs,i))) classname: (sClassName)
25 #-->RESULT ecode:intValue objids:list
26
27 SETL lObjids: (lObjids + objids + " ")
28 }
29 FOR i from: (0) to: (tokcnt(lObjids)-1) {
30 CC "Core" SET_ATTR_VAL objid: (VAL (token(lObjids,i)))attrname: (sAttrName) val: (sAttrVal)
31 }
32 }
33}
3) GET_ALL_MODELIDS procedure:
1PROCEDURE global GET_ALL_MODELIDS lModelIDs:string nStartingPointForSearch:integer result:reference
2{
3 CC "Documentation" GET_MODEL_GROUP_TREE_XML
4 #--> RESULT ecode:intValue xml:strValue
5
6 SETL nClosingRootTagPosition: (search(xml,"</root>",nStartingPointForSearch))
7 WHILE (nStartingPointForSearch < nClosingRootTagPosition) {
8 SETL nStartPositionOfGroupTag: (search(xml,"<model",nStartingPointForSearch))
9 SETL nEndPositionOfGroupTag: (search(xml,">",nStartPositionOfGroupTag))
10 SETL sModelID: (copy(xml,search(xml,"=",nStartPositionOfGroupTag) + 2,
11 (search(xml,"name",nStartPositionOfGroupTag) - search(xml,"=",nStartPositionOfGroupTag)-4)))
12 SETL nStartingPointForSearch: (nEndPositionOfGroupTag)
13
14 IF (nStartingPointForSearch = -1) {
15 BREAK
16 }
17 SETL lModelIDs: (lModelIDs + sModelID + " ")
18 }
19 SETL result: (lModelIDs)
20}