# -----------------------------------------------------------------------
# ----------------  AfterEditAttibuteValue EVENT -----------------------------
# -----------------------------------------------------------------------



# SETG n_currModeld: (modelid)
# SETG n_chAttrId: (attrid)
# SETG n_instId: (instid)

# instid	intValue, the ID of the changed instance.
# attrid	intValue, the Attribute ID.
# modelid	intValue, the ID of the model containing the changed instance.
# attrtypeid	intValue, the Attribute type code as follows: 
# 0 INTEGER, 1 DOUBLE, 2 STRING, 3 DISTRIBUTION, 4 TIME, 5 ENUMERATION,
# 6 ENUMERATIONLIST, 7 LONGSTRING, 8 PROGRAMCALL, 9 INTERREF, 10 EXPRESSION, 
# 11 RECORD, 12 ATTRPROFREF, 13 DATE, 14 DATETIME, 15 CLOB


# ---- Getting the Class ID of the instanced object
CC "Core" GET_CLASS_ID objid: (n_instId)
	#--> RESULT ecode:intValue classid:intValue
	SET n_chClassID: (classid)


# ---- Getting the Class ID of the Class with the name "Task"  
CC "Core" GET_CLASS_ID classname: "Task"
	#--> RESULT ecode:intValue classid:intValue
	SET n_TaskClassID: (classid) 

# ---- Getting the Attribute ID of the Attribute with name "Name" and Class ID "n_TaskClassID" 	
CC "Core"  GET_ATTR_ID classid:(n_TaskClassID) attrname:"Name"
#-->RESULT ecode:intValue attrid:id
SET m_TaskNameID: (attrid)

 
# ---- IF "m_TaskPosID" equals "n_chAttrId" THEN Getting the Attribute Value of Attribute with name "Name" and setting the result to "s_newName"
IF (m_TaskNameID = n_chAttrId) { 
CC "Core" GET_ATTR_VAL objid: (n_instId) attrname: "Name"
SET s_newName:(val)

# ---- Getting Attribute value of instanced object with Attribute "StartName" and setting the result to "s_startName"
CC "Core" GET_ATTR_VAL objid: (n_instId) attrname: "StartName"
SET s_startName:(val)


	# ---- If these two Names are the same then...
	IF ( s_newName = s_startName) {
	
	# ---- Get the Attribute value of Attribute with Attributename "Accept all changes to object" and set the result to "v_Accept all changes to objectVal"
	CC "Core" GET_ATTR_VAL objid: (n_instId) attrname: "Accept all changes to object"
	SET SET v_Accept all changes to objectVal: (val)
	
	# ---- Set the Attribute value of Attribute with Attributename "Accept all changes to object" to "Yes"
	CC "Core" SET_ATTR_VAL objid: (n_instId) attrname: "Accept all changes to object" val: "Yes"
	#-->RESULT ecode:intValue attrid:id	
	}
	
	
	 # ---- If this is not the case then...
	 ELSE {
	 # ---- Get the Attribute value of Attribute with Attributename "Accept all changes to object" and set the result to "v_Accept all changes to objectVal"
	 CC "Core" GET_ATTR_VAL objid: (n_instId) attrname: "Accept all changes to object"
	 SET SET v_Accept all changes to objectVal: (val)
	
	 # ---- Set the Attribute value of Attribute with Attributename "Accept all changes to object" to "No"
	 CC "Core" SET_ATTR_VAL objid: (n_instId) attrname: "Accept all changes to object" val: "No"
	 #-->RESULT ecode:intValue attrid:id	
	 }


	
}

# ----IF Attribute "Accept all changes to objects" is changed to YES, then set AttributeValue from "Name" to AttributeValue of "StartName"
	
	# ---- GET the Value of Attribute "Accept Changes" (Expecting a YES here) and SET the result to new Variable
	CC "Core" GET_ATTR_VAL objid: (n_instId) attrname: "Accept all changes to object"
	#-->RESULT ecode:intValue attrid:id
	SET v_AcceptValNew: (val)
	
	# ---- IF this new Variable is equal to "YES" then...
	IF (v_AcceptValNew = "Yes" ) {
	
		# ---- GET the Value of Attribute "Name" and SET it to Variable "s_updatedName"
		CC "Core" GET_ATTR_VAL objid: (n_instId) attrname: "Name"
		SET s_updatedName:(val)
		
		# ---- 
		CC "Core" SET_ATTR_VAL objid: (n_instId) attrname: "StartName" val: (s_updatedName)
		#-->RESULT ecode:intValue attrid:id	
	}