| 4D v18CALL FORM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|  | 
    4D v18
 CALL FORM 
         | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CALL FORM ( window ; method {; param}{; param2 ; ... ; paramN} ) | ||||||||
| Parameter | Type | Description | ||||||
| window | WinRef |   | Window reference number | |||||
| method | Text |   | Name of project method to call | |||||
| param | Expression |   | Parameter(s) passed to method | |||||
The CALL FORM command executes the project method whose name you passed in method with the optional param(s) in the context of a form displayed in a window, regardless of the process owning the window.
Just like in the worker-based interprocess communication feature (see About workers), a message box is associated with the window and can be used when the window displays a form (after the On Load form event). CALL FORM encapsulates the method name and its arguments in a message that is posted in the window's message box. The form then executes the message in its own process. The calling process can be cooperative or preemptive, thus this feature allows a preemptive process to exchange information with forms.
In window, you pass the window reference number of the window displaying the called form.
In method, you pass the name of the project method to be executed in the context of the window parent process.
You can also pass parameters to the method using one or more param parameters. You pass parameters the same way you would pass them to a subroutine (see the Passing Parameters to Methods section). Upon starting execution in the context of the form, the method receives the parameter values in $1, $2, and so on. Remember that arrays cannot be passed as parameters to a method. Furthermore, in the context of the CALL FORM command, the following additional considerations need to be taken into account:
You want to open two different dialog windows from the same form, but with different background colors and different messages. You also want to send messages afterwards and display them in each dialog window.
In the main form, a button opens the two dialogs:
  //Object method to create forms
  //First window
 formRef1:=Open form window("FormMessage";Palette form window;On the left)
 SET WINDOW TITLE("MyForm1";formRef1)
 DIALOG("FormMessage";*)
 SHOW WINDOW(formRef1)
 
  //Second window
 formRef2:=Open form window("FormMessage";Palette form window;On the left+500)
 SET WINDOW TITLE("MyForm2";formRef2)
 DIALOG("FormMessage";*)
 SHOW WINDOW(formRef2)
 
  //Send colors
 CALL FORM(formRef1;"doSetColor";0x00E6F2FF)
 CALL FORM(formRef2;"doSetColor";0x00F2E6FF)
  //Create messages
 CALL FORM(formRef1;"doAddMessage";Current process name;"Hello Form 1")
 CALL FORM(formRef2;"doAddMessage";Current process name;"Hello Form 2")The doAddMessage method only adds a row in the list box in the "FormMessage" form:
 C_TEXT($1) //Caller name
 C_TEXT($2) //Message to display
  //Receive message from $2 and log the message in the list box
 $p:=OBJECT Get pointer(Object named;"Column1")
 INSERT IN ARRAY($p->;1)
 $p->{1}:=$1+" sends "+$2At runtime, you get the following result:

You can then add other messages by executing the CALL FORM command again:
 CALL FORM(formRef1;"doAddMessage";Current process name;"Hello 2 Form 1")
 CALL FORM(formRef2;"doAddMessage";Current process name;"Hello 2 Form 2")
You can use the CALL FORM command to pass custom settings to a form, for example configuration values, without having to use process variables:
 $win:=Open form window("form")
 CALL FORM($win;"configure";param1;param2)
 DIALOG("form")
	Product:  4D
	Theme:  Form Events
	Number:  
        1391
        
        
        
	
	Created:  4D v15 R5
	Modified:  4D v16 R4
	
	
	
	
	
	
	
	
	
	
	
	4D Language Reference ( 4D v18)
	
	
	
	
	
 Add a comment
Add a comment