Im trying to get userinterface objects to communicate with a datastore using event objects. The datastore is receiving new data and distributing it to anyone interested.
I can get all the inter object relations to work however, without any data transfer. I.e. I can create a notification that data is changed but I cant distribute the data with the notification. The code Im using is the following:
I try to transfer data with the notifications (as indicated by the out commented method parameters). However, powerbasic gives a compile error when I remove the comment signs (Error 481 Mismatch with prior definition). What am I doing wrong?
If this data transfer is not possible can I determine where (i.e. which object instance) the notification came from so I can get the data from the notifier?
Thanks in advance
Rogier
I can get all the inter object relations to work however, without any data transfer. I.e. I can create a notification that data is changed but I cant distribute the data with the notification. The code Im using is the following:
Code:
INTERFACE NewDataEv AS EVENT INHERIT IUNKNOWN METHOD NameChanged '(BYVAL Into$) END INTERFACE INTERFACE StoreData INHERIT IUNKNOWN METHOD DoReceiveANewName '(IN NewName$) END INTERFACE '--- Object defs CLASS UserInterfaceClass1 AS EVENT INSTANCE DataStoreObj AS StoreData INTERFACE NewDataEv AS EVENT INHERIT IUNKNOWN METHOD NameChanged '(BYVAL Into$) MSGBOX "1. Changed into " '+ Into$ END METHOD END INTERFACE INTERFACE GetUserInput AS EVENT INHERIT IUNKNOWN METHOD SetDataStore (a AS StoreData) DataStoreObj = a END METHOD METHOD AskForAName MSGBOX "A new name created" DataStoreObj.DoReceiveANewName '("New Name") END METHOD END INTERFACE END CLASS '------------- CLASS UserInterfaceClass2 AS EVENT INSTANCE DataStoreObj AS StoreData INTERFACE GetUserInput AS EVENT INHERIT IUNKNOWN METHOD SetDataStore (a AS StoreData) DataStoreObj = a END METHOD METHOD AskForAName MSGBOX "A new name created" DataStoreObj.DoReceiveANewName '("New Name") END METHOD END INTERFACE INTERFACE NewDataEv AS EVENT INHERIT IUNKNOWN METHOD NameChanged '(BYVAL Into$) MSGBOX "2. Changed into " '+ Into$ END METHOD END INTERFACE END CLASS '------------- CLASS MyDataStore INTERFACE StoreData INHERIT IUNKNOWN METHOD DoReceiveANewName '(in NewName$) MSGBOX "A New Name..." + NewName$ RAISEEVENT NewDataEv.NameChanged '("New name") END METHOD END INTERFACE EVENT SOURCE NewDataEv END CLASS FUNCTION PBMAIN() DIM oDataStore AS StoreData LET oDataStore = CLASS "MyDataStore" ' An UI object which reads input and displays it DIM oInputPart AS GetUserInput : LET oInputPart = CLASS "UserInterfaceClass1" ' the input part of the UI object DIM oDisplayNameTxt AS NewDataEv : LET oDisplayNameTxt = oInputPart ' the display part of the UI object oInputPart.SetDataStore (oDataStore) ' An UI object which displays changed data DIM oNameButton AS NewDataEv : LET oNameButton = CLASS "UserInterfaceClass2" ' Only display data EVENTS FROM oDataStore CALL oDisplayNameTxt EVENTS FROM oDataStore CALL oNameButton oInputPart.AskForAName EVENTS END oDisplayNameTxt EVENTS END oNameButton END FUNCTION
If this data transfer is not possible can I determine where (i.e. which object instance) the notification came from so I can get the data from the notifier?
Thanks in advance
Rogier
Comment