Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Usage of PROCEDURE
Answer
2/24/16 5:44 PM
Hello,

I've got problems with the call of PROCEDUREs. I don't see any usage of the reference prameter in the documentation.

What I understand:
Attribute parameters with value parameters is a normal read-only IN-Paramter (Call by value)
Attribute parameters with reference parameters is  read-write IN-OUT-Paramter (Call by reference)

I try to define a global PROCEDURE which should be called in some EVENTs.
 1#===============================================
 2#---- INIT GLOBAL VARS
 3ON_EVENT "AppInitialized"
 4{
 5    PROCEDURE global GET_POOL_NAME modelid: integer instid: integer result: reference
 6    {
 7        #get the class_id of the object
 8        CC "Core" GET_CLASS_ID objid:instid
 9        SET class_id: (classid)
10       
11        #get pool class_id
12        CC "Core" GET_CLASS_ID classname:("Pool")
13        SET pool_class_id:(classid)
14       
15        #only NOT pools should go on
16        IF (class_id <> pool_class_id) {
17            CC "Core" GET_ATTR_VAL objid: (instid) attrname: ("Position")
18            SET my_position: (val)
19            SET result:("Drin")
20        }
21        ELSE {
22            SET result:("Draußen")
23       }
24
25    }
26}
27
28
29ON_EVENT "CreateInstance"
30{
31    SET my_classid: (classid)
32    SET my_instid: (instid)
33    SET my_modelid: (modelid)
34    SET pool_name: ("")
35
36    GET_POOL_NAME modelid:(my_modelid) instid:(my_instid) result:(pool_name)
37
38    CC "Core" GET_ATTR_ID classid: (my_classid) attrname: ("Pool name")
39    SET pool_name_attrid: (attrid)
40    CC "Core" SET_ATTR_VAL objid: (my_instid) attrid: (pool_name_attrid) val: (pool_name)      
41}


When opening a model the error-message(s) pops up. (see attached)

How do i define a reference attribute?

Greetings,
Swante
Attachment

Attachments: error.png (7.8k)

RE: Usage of PROCEDURE
external coupling adoscript procedure
Answer
12/7/17 1:04 PM as a reply to Swante.
The error is because of the brackets for the result parameter in the call of the GET_POOL_NAME procedure. The call should look like the following:
1GET_POOL_NAME modelid: (my_modelid) instid: (my_instid) result: pool_name