KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Positive or negative numbers when retrieving variables from a different process
PRODUCT: 4D | VERSION: | PLATFORM: Mac
Published On: April 18, 2002

Version: 6.5.x and 6.7.x

You may need to retrieve the value of process variables from a different process. Depending on where you want to execute these commands, process IDs can be either negative or positive.

If you try to retrieve a value located in a different process that is currently running in the same application, the value must be a positive number. This would be the case where Process A wants to read variables from process B and both processes are running in the same application. For example, two processes running on the same 4D Client, two stored procedures running on the server, or 2 processes running on 4D single user.

If a 4D Client wants to retrieve the value of the variable stored in a stored procedure, you will need to use a negative process number. The process number should be the process number that you can see on the Server side. Negative process number are used to differentiate between the local process numbers and the 4D Server numbers.

If you want to retrieve an interprocess variable, you may use an existing process number such as -2 or -3 since interprocess variables are shared by all processes running on the same application.

If you want to retrieve a variable from one specific stored procedure, you will need to use its actual process number.

You cannot directly retrieve a variable from a 4D Client from another 4D Client. The workaround here would be to use the command EXECUTE ON CLIENT. The Client may request the variable from a stored procedure. This stored procedure will ask the other Client to execute a method that will copy the requested variable onto the Server side. Once this is done, the first client can read this variable from the server-side process.