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

In the 4D Client/Server environment there are times when the need arises to learn, from the client, what processes are running on the server. There are no 4D commands that give the client direct access to 4D Server Process information. However, with that introduction in 4D v11 SQL of the method property "Execute on Server", information about 4D Server processes can easily be gained programmatically.

To do so follow these steps:

  • Create a method

  • Set its method property to "Execute on Server"

  • Paste the contents of the method below into your method

The method below returns the information from the 4D command PROCESS PROPERTIES. The method would be called as shown:

ARRAY STRING(31;ProcName_aA31;0)
ARRAY INTEGER(ProcNum_aI;0)
ARRAY LONGINT(State_aL;0)
SVR_ProcessList (->ProcName_aA31;->ProcNum_aI;->State_aL)


And here is the method to call (be sure to set its property "Execute on Server"):

If (True)
  If (False)
    `*****************************************************************************
    `//
    `// SVR_ProcessList (->ProcName_aA31;->ProcNum_aI;->State_aL)
    `//
    `// $1 - POINTER - Pointer to a string array for Process names
    `// $2 - POINTER - Pointer to a integer array for Process numbers
    `// $3 - POINTER - Pointer to a longint array for Process states
    `//
    `*****************************************************************************

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

  C_POINTER($ProcName_P;$1)
  C_POINTER($ProcNum_P;$2)
  C_POINTER($State_P;$3)
  `--------------------------------------------------------------------------------
  `method_wide_constants_declarations
  `--------------------------------------------------------------------------------
  `local_variable_declarations

  C_LONGINT($Ndx;$SOA;$Count_L;$Time_L)
  
End if
`======================   Initialize and Setup   ================================

$ProcName_P:=$1
$ProcNum_P:=$2
$State_P:=$3

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

$SOA:=Count tasks
ARRAY STRING(31;$ProcName_P->;$SOA)
ARRAY INTEGER($ProcNum_P->;$SOA)
ARRAY LONGINT($State_P->;$SOA)
$Count_L:=0

For ($Ndx;1;$SOA)
  If (Process state($Ndx)>=Executing )
    $Count_L:=$Count_L+1
    PROCESS PROPERTIES($Ndx;$ProcName_P->{$Count_L};$State_P-> {$Count_L}; $Time_L)
    $ProcNum_P->{$Count_L}:=$Ndx
  End if
End for

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

` Eliminate unused extra elements

ARRAY STRING(31;$ProcName_P->;$Count_L)
ARRAY INTEGER($ProcNum_P->;$Count_L)
ARRAY LONGINT($State_P->;$Count_L)