Publish/Subscribe Question

Hi

Progress 9.1e 02 Windows xp
Using ADM2

I have a Smart Container with SDO, smart Browser and 2 SD viewers on it.
From the Smart Container I am doing
PUBLISH "viewit" (INPUT viewit).
(From procedure InitializeObject)

In the SD viewer I am doing
SUBSCRIBE TO "viewit" ANYWHERE.
(in the DisplayFields procedure)

I have the Procedure viewit set up as
DEFINE INPUT PARAMETER viewit AS LOGICAL NO-UNDO.
doview = viewit.
/*MESSAGE "in view2 with " doview VIEW-AS ALERT-BOX.*/
END PROCEDURE.

The problem is that the viewit is not being called the first time the program is run,
But when Navigating through the records viewit is set up perfectly.

So the question is where (in which Procedure(s)) should I put the SUBSCRIBE/PUBLISH ??

regards
Mike
 
All the SUBSCRIBE statement does is registers an interest in the published event, so you would normally only want it to be executed once for the subscriber.

ie. from what you've said, the SUBSCRIBE should go in InitializeObject of SDV.

The PUBLISH should be put wherever you want the Event to be triggered.

Bear in mind that some PUBLISH/SUBSCRIBE stuff can be implemented with SmartLinks.

There is a tool called ProSpy++ in your installation which will show you all the ADM2 calls made by your application in Tree fashion for further investigation.
 
Publish / Subscribe could be explained in simple terms. Subscribe is like you switching on a radio frequency in your radio. Publish is like some program being transmissitted from that station. Similar to the fact that you have to switch on the radio first to receive the transmission from that station, you have to subscribe first and then publish the event from an event / procedure / function. It is desirable that you do not Subscribe to "ANYWHERE" in your program, even though it works, since you or other developers in your team will have a hard time tracking it down.
 

lord_icon

Member
PUBLISH / SUBSCRIBE method. This is loose coupling.

PUBLISH
Real world definition. Is any object interested if this process occurs.

SUBSCRIBE
Real world definition. I am an object that would like to know when a process occurs.

Hope this helps in understanding the syntax.
 
Hi
Thanks for everyone's reply.

The reason why I have asked is that we are converting an 'old' Character version into GUI.

The old version had lots of Global shared variables and I am trying not to use this method.

I want to 'pass' variables from Containers to Smart Viewers and back again in the most convenient way and I was sort of told that to use Publish/Subscribe was the way to go.

If anyone can suggest a better/easier/more dependable structure I will be most grateful.

Regards

Mike
 
Top