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 Initialize Webroutine by keying a URL into their browser. It places a value into DEPTMENT.

The Transfer command then transfers control to the ShowPage 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 ShowPage 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 ShowPage's web page.

Note that the Endroutine command of the Initialize Webroutine is never executed, as control is transferred to ShowPage. Consequently, no page shows for the Initialize 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 ShowPage 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.