/ Forums / Advansys Formativ / Creating Solutions with Formativ / How to call code in another applet? / Reply To: How to call code in another applet?

#7297
Support 3
Participant

ChainApplet 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