KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Getting the State of Server Processes from Client
PRODUCT: 4D Server | VERSION: 11.5 | PLATFORM: Mac & Win
Published On: February 11, 2010

Before attempting to acquire the values of the variables in a stored procedure on 4D server, it is advisable to acquire the state of the process. You want to do this before making a call to the process using the 4D commands GET PROCESS VARIABLE or VARIABLE TO VARIABLE.

However, the normal 4D command for getting the state of a process, Process state, will only return the state or processes of the client. The method below will return the state of a process on the server. To use it, create a method, set the method property to "Execute on Server", and then paste the code below into method.

Call the method with the name of the target server process and it will return the 4D constant for the current state of the server process.

If (True)
   If (False)
      `*****************************************************************************
      `//
      `// SVR_ProcessState ($ProcName_T) -> State
      `//
      `// Purpose: Get the process state for one process on the server
      `//
      `// $0 - LONGINT - Process state constant
      `// $1 - STRING - Process name
      `//
      `*****************************************************************************

   End if
   C_TEXT($MethodName_T)
   $MethodName_T:=Current method name
   `=====================   Declare Variables   ==================================
   `method_parameters_declarations

   C_LONGINT($0;$State_L)
   C_STRING(40;$ProcName_T;$1)
   `--------------------------------------------------------------------------------
   `method_wide_constants_declarations
   `--------------------------------------------------------------------------------
   `local_variable_declarations

   C_LONGINT($Ndx)
   
End if
`======================   Initialize and Setup   ================================

$ProcName_T:=$1

`========================   Method Actions   ==================================

$Ndx:=Process number($ProcName_T)
$State_L:=Process state($Ndx)

`========================   Clean up and Exit   =================================

$0:=$State_L