/ Forums / Advansys Formativ / Creating Solutions with Formativ / How to call code in another applet?
-
CreatorTopic
-
September 19, 2005 at 4:41 am #4158
Hi,
is there a way to caal a piece of code in another applet?
If a message arrives, my applet is doing some things, and based on several parameters I would like to do something more. Do I have to put everything in 1 (one) applet, or is there a methods to call one applet from another?
Thanks,
Jeroen
-
CreatorTopic
-
AuthorReplies
-
September 19, 2005 at 4:17 pm #7293
Dear Jeroen,
You cannot call a function in one applet from another. However, you can have one applet call another once the calling applet has finished running. See ‘ChainApplet’ in the Language Guide for full details.
Regards,
Advansys Support
June 16, 2008 at 5:31 am #7295Is this still true for version 2.0 of Formativ? It would certainly be a very helpful feature for code reuse.
June 16, 2008 at 2:15 pm #7296Yes, you can call another Applet using the ChainApplet() method. See the Formativ language guide for more information. See below the comments from the language guide.
quote:
utilities.ChainApplet: String
Example:
Utilities.ChainApplet = “Message Notes_flexalock”Applet Chaining makes it possible to build interaction solutions based on two or more discrete Applets. Specify the applet you wish to chain by providing it’s name to the Utilities.ChainApplet property. Only the applet name needs to be supplied, though the full path may optionally be supplied. When the applet containing this line finishes executing, the applet indicated by Utilities.ChainApplet will be automatically executed (assuming the applet is available).
You can only specify one Chain Applet at a time. If your Applets makes two calls to ChainApplet, only the most recent call will take affect. The applet you specify in the Utilities.ChainApplet property does not get executed until the current applet finishes.
Formativ 2.0 also introduces the concept of Applet Data Exchange, which makes it easy for one applet to pass data to another via a global ‘scratch pad’. This feature can be used to pass data between Applets during chaining. See the TransferData property for more information.
On a separate note, you can also use the Formativ API (COM/XML based API) to interact with Formativ from processes external to GroupWise. See the URL below for more information.
http://www.advansyscorp.com/forums/topic/4131090521/Regards,
Advansys SupportJune 17, 2008 at 5:26 am #7294I am fairly new to Formativ and I do not see how the ChainApplet() method would allow you to call a function in another applet and then return a value.
It seems to me that things could get very messy trying to pass values through the Utilities.TransferData property and the whole business of the first applet having to quit before the other one can start and then start up the calling applet to receive the value would really affect performance.
Can you elaborate more on the technique?
June 17, 2008 at 2:59 pm #7297ChainApplet method lets you to call another applet (i.e. “Applet2”) once the calling applet (i.e “Applet1”) has finished running.
You cannot call a specific function in one applet using this method. For example, you can not call a function in “Applet2”. Formativ will execute the applet, if the chainapplet method used in the source then Formativ will execute the chained applet. You can pass data between applet using the TransferData property.
Not sure whether it will help, you can also use the ChainApplet method to return to the calling applet.
For example:
– Applet1 use the ChainApplet to call Applet2. You can write your exit code after the ChainApplet method so the Applet1 stop immediately after it calling the ChainApplet.
– Applet2 will execute, you can add ChainApplet in Applet2 to call Applet1.See below an example:
– Create a Applet called “Applet1” and paste the source code below.
'------------------------------------------------------------------------------- ' Applet1 '------------------------------------------------------------------------------- Sub Main(Client, GWEvent) if (utilities.ExecutionSource = esApplet) then msgbox "Applet1 running now. It was executed by the Applet2" else msgbox "Applet1 running. Now it will call Applet2" CallChainApplet("Applet2") exit sub end if End Sub function CallChainApplet(appletName) Utilities.ChainApplet = appletName end function
– Create a Applet called “Applet2” and paste the source code below.
'------------------------------------------------------------------------------- ' Applet2 '------------------------------------------------------------------------------- Sub Main(Client, GWEvent) msgbox "Applet2 rinnung. Now it will call Applet1" CallChainApplet("Applet1") End Sub function CallChainApplet(appletName) Utilities.ChainApplet = appletName end function
Regards,
Advansys Support -
AuthorReplies
- You must be logged in to reply to this topic.