4D v16.3New process |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
New process
New process
The New process command starts a new process (on the same machine) and returns the process number for that process. If the process could not be created (for example, if there is not enough memory), New process returns zero (0) and an error is generated. You can catch this error using an error-handling method installed using ON ERR CALL. In method, you pass the name of the process method for the new process. After 4D has set up the context for the new process, it starts executing this method, which therefore becomes the process method. The stack parameter allows you to indicate the amount of memory allocated for the stack of the process. This is the space in memory used to “pile up” method calls, local variables, parameters in subroutines, and stacked records.
Note: The stack is NOT the total memory for the process. Processes share memory for records, interprocess variables, and so on. A process also uses extra memory for storing its process variables. The stack contains various items of 4D information; the amount of information kept on the stack depends on the number of nested method calls the process will employ, the number of forms that it will open before closing them and the number and size of local variables used in each nested method call. Note for 64-bit 4D Server: The stack for a process executed on a 64-bit 4D Server usually requires more memory than on a 32-bit 4D Server (about twice as much). Make sure that you check this parameter when your code is intended for execution on a 64-bit 4D Server. You pass the name of the new process in name. This name will appear in the list of processes of the Runtime Explorer and will be returned by the PROCESS PROPERTIES command when applied to this new process. You can omit this parameter; if you do so, the name of the process will be the empty string. You can make a process local in scope by prefixing its name with the dollar sign ($). Important: Remember that local processes should not access data in Client/Server. You can pass parameters to the process method using one or more param parameters. You pass parameters in the same way as you would pass them to a subroutine (see the Passing Parameters to Methods section). Upon starting execution in the context of the new process, the process method receives the parameters values in $1, $2, etc. Remember that arrays cannot be passed as parameters to a method. Furthermore, these additional considerations are to be taken into account in the context of the New process command:
Note: If you pass parameters to the process method, you must pass the name parameter; it cannot be omitted in this case. Specifying this last parameter tells 4D to first check whether or not a process with the name you passed in name is already running. If it is, 4D does not start a new process and returns the process number of the process with that name. Given the following project method: ` ADD CUSTOMERS If you attach this project method to a custom menu item Menu Bar Editor window whose Start a New Process property is set, 4D will automatically start a new process running that method. The call SET MENU BAR(1) adds a menu bar to the new process. In the absence of any window (that you could open with Open window), the call to ADD RECORD will automatically open one. To be able to start this Add Customers process when you click on a button in a custom control panel, you can write: ` bAddCustomers button object method The button does the same thing as the custom menu item. While choosing the menu item or clicking the button, if you want to start the process (if it does not exist) or bring it to the front (if it is already running), you can create the method START ADD CUSTOMERS: ` START ADD CUSTOMERS The object method of the bAddCustomers becomes: ` bAddCustomers button object method In the Menu Bar editor, you replace the method ADD CUSTOMERS with the method START ADD CUSTOMERS, and you deselect the Start a New Process property for the menu item.
See also
Execute on server
|
PROPERTIES
Product: 4D HISTORY
Modified: 4D 2004.3 ARTICLE USAGE
4D Language Reference ( 4D v16) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||