In the previous lesson you created a single procedure for handling multiple events and stored it to the common DocumentProcessing module. In particular, you set the Client (managed application) checkbox and cleared the Server checkbox in the module properties. The procedure is called from the form module where the event handler also has a directive that specifies the execution context for this handler: &AtClient. Now we will explain how the script is executed in this scenario.
When an application is started, script execution is always started on the client. Then the script execution can be passed to the server by calling a procedure of a common module compiled on the server.
When a procedure or function is called, the platform searches for it on a client first. If the compiled client context does not contain this procedure, the search continues on the server. If the procedure is found, the script execution is passed to the server. When the procedure is execution is completed, the script execution continues on the client.
For example, when you change a price in a goods receipt form, the PriceOnChange() procedure of the form module is called. It is executed on the client in the thin client mode. The second line of this handler calls the CalculateTotal() procedure. This procedure is located in the common DocumentProcessing module, which is also compiled on the client. It is executed in the thin client mode. Once the procedure is executed, the execution is passed back to the form module (fig. 5.49).
Fig. 5.49. Passing script execution between client modules
Go to the next lesson: Lesson 6 (0:50). Accumulation registers