Process number

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 6.0


Process number (name{; *}) Number

ParameterTypeDescription
nameStringName of process for which to retrieve
the process number
*Return the process number from the server
Function resultNumberProcess number

Description

Process number returns the number of the process whose name you pass in name. If no process is found, Process number returns 0.

The optional parameter * allows you to retrieve, from 4D Client, the process ID of a process that is executed on the server (a stored procedure). In this case, the returned value is negative. This option is especially useful when using the GET PROCESS VARIABLE and SET PROCESS VARIABLE commands. Please refer to the descriptions of these commands for details.

If the command is executed with the * parameter from a process on the server machine, the returned value is positive.

Example

You create a custom floating window, run in a separate process, in which you implement your own tools to interact with the Design environment. For example, when selecting an item in a hierarchical list of keywords, you want to paste some text into the frontmost window of the Design environment. To do so, you can use the clipboard, but the pasting event must occur within the Design process. The following small function returns the process number of the Design process (if running):

      ` Design process number Project Method
      ` Design process number -> LongInt
      ` Design process number -> Design process number

   $0:=Process number(Get indexed string(170;3))
      ` The name of the Design process is stored in the 'STR#" resource ID=170, string #3 within 4D
      ` Note: This can break in the future if the resource changes

Using this function, the following project method pastes the text received as parameter to the frontmost window of the Design environment (if applicable):

      ` PASTE TEXT TO DESIGN Project Method
      ` PASTE TEXT TO DESIGN ( Text )
      ` PASTE TEXT TO DESIGN ( Text to Paste in frontmost Design window )

   C_TEXT($1)
   C_LONGINT($vlDesignPID;$vlCount)

   $vlDesignPID:=Design process number 
   If ($vlDesignPID # 0)
         ` Put the text into the clipboard
      SET TEXT TO CLIPBOARD($1)
         ` Post a Ctrl-V / Command-V event
      POST KEY(Ascii("v");Command key mask;$vlDesignPID)
         ` Call repeatedly DELAY PROCESS so the scheduler gets a chance
         ` to pass over the event to the Design process
      For ($vlCount;1;5)
         DELAY PROCESS(Current process;1)
      End for 
   End if 

See Also

GET PROCESS VARIABLE, PROCESS PROPERTIES, Process state, SET PROCESS VARIABLE.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next