GenTrigger: 3.1 Supplemental GenTrigger Usage: Passing Data with a GenTrigger

Up: GEOS SDK TechDocs | Up | Prev: 3 Supplemental GenTrigger Usage | Next: 3.2 Interaction Commands
ATTR_GEN_TRIGGER_ACTION_DATA, ATTR_GEN_TRIGGER_ACTION_TWO_WORDS, ATTR_GEN_TRIGGER_ACTION_THREE_WORDS

A GenTrigger may pass data along with its message. Use ATTR_GEN_TRIGGER_ACTION_DATA to assign a word of data that you wish to pass with the particular message. If you need to pass more than a single word of data, you will have to use @vardataAlias ; this Goc keyword allows ATTR_GEN_TRIGGER_ACTION_DATA to pass a structure instead of a single word.

Several ATTR_GEN_TRIGGER_ACTION_DATA aliases already exist for your use. ATTR_GEN_TRIGGER_ACTION_TWO_WORDS and ATTR_GEN_TRIGGER_ACTION_THREE_WORDS allow you to pass two or three words of data along with the trigger's message .

If you need to pass more than three words of data with a message, you will need to use the stack to pass arguments. To do so, use the @stack parameter within your message definition; because of the implementation of the stack, make sure to set up your structure to pass its arguments in reverse order .

Code Display 5-3 Passing Data from a GenTrigger

/* In a class declaration, you should define a message that passes data. */
@class MyProcessClass, GenProcessClass;
@message void MSG_SET_MY_DATA(int myData);
@endc;
@object GenTriggerClass MyHundredTrigger = {
	/* This trigger will pass 100 to the method for MSG_SET_MY_DATA. */
    GI_visMoniker = "Set My Data to 100";
    GTI_actionMsg = MSG_SET_MY_DATA;
    GTI_destination = process;
    ATTR_GEN_TRIGGER_ACTION_DATA = 100;					/* This object's data is 100. */
}
@object GenTriggerClass MyTenTrigger = {
	/* This trigger will pass `10' to the method for MSG_SET_MY_DATA.*/
    GI_visMoniker = "Set My Data to 10";
    GTI_actionMsg = MSG_SET_MY_DATA;
    GTI_destination = process;
    ATTR_GEN_TRIGGER_ACTION_DATA = 10;					/* This object's data is 10. */
}
@method MyProcessClass, MSG_SET_MY_DATA {
	/* This message passes one parameter (the integer myData). Goc knows
	 * that the data is located within the ATTR_GEN_TRIGGER_ACTION_DATA
	 * field. */
    UpdateDisplay(myData);				/* Use that data for your own purposes. */
}
/* The following examples show how to pass longer structures than the above. */
	/* Define the message. */
@message void MSG_CUSTOM_MESSAGE(@stack char name[10], optr arg1, int arg2);
	/* Define the structure you wish to pass with the message. If the
	 * message will pass parameters on the stack (as in this case), you
	 * must define your structure to pass its elements in reverse order. */
typedef struct { 
    int		MS_arg2;
    optr		MS_arg1;
    char		MS_name[10]
} MyStruct;
	/* Use @vardataAlias to define your own attribute (ATTR_MY_STRUCT_TO_PASS)
	 * to store the custom structure. */
@vardataAlias (ATTR_GEN_TRIGGER_ACTION_DATA) MyStruct ATTR_MY_STRUCT_TO_PASS;
	/* Declare your object and set the arguments to pass. */
@object GenTriggerClass MyTrigger = {
    GI_visMoniker = "Custom Trigger";
    GTI_actionMsg = MSG_CUSTOM_MESSAGE;
    GTI_destination = process;
    ATTR_MY_STRUCT_TO_PASS = { 100, @ListObject, "Zow!" }
}

Up: GEOS SDK TechDocs | Up | Prev: 3 Supplemental GenTrigger Usage | Next: 3.2 Interaction Commands