Controlling Webroutine Flow Programmatically
As well as Webroutines being executed from the Presentation Layer, which is described later, they can also be executed under program control using the Call and Transfer RDML commands. Consider the following code:
Imagine that the user executes the
Webroutine by keying a URL into their browser. It places a value into DEPTMENT.The Transfer command then transfers control to the
Webroutine, which accepts DEPTMENT's value. Note that the appropriate mapping takes place as part of the transfer, according to the web map definitions for the current Webroutine. The Webroutine doesn't actually do anything, but ends, outputting DEPTMENT's value as it does. Control is then passed to the Presentation Layer, which shows web page.Note that the Endroutine command of the
Webroutine is never executed, as control is transferred to ShowPage. Consequently, no page shows for the Webroutine.This use of Transfer illustrates a slightly more advanced technique, whereby a single Webroutine in the WAM can be responsible for showing the Presentation Layer. Using this technique, all other Webroutines can be used solely to perform Application Logic. All of them transfer control to the
Webroutine as the last thing they do.You may find that this technique can simplify your application. What this means is that your application may be made up of multiple WAMs, each WAM using only one Webroutine to display a web page. To further support this, the Transfer command also supports transfer between WAMs:
The Call command is similar to the Transfer command in that it executes a Webroutine. The difference is that control is not transferred – the Webroutine is executed fully, right through to the Endroutine command and control is then returned to the executing Webroutine. Note that the web page for the called Webroutine is not shown.