KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: A utility to launch any process into a new process
PRODUCT: 4D | VERSION: 13.3 | PLATFORM: Mac & Win
Published On: August 8, 2013

The utility below can be called by any method to launch a new process for that method.

If (True)
   If (False)
       //*****************************************************************************
       //
       // Shell_SelfStart
       //
       // Purpose: Launch the caller into a new process
       //
       // $1 - TEXT - Calling method name
       // $2 - TEXT - New process name
       // $3 - BOOL - Froce a new process
       //
       //*****************************************************************************
   End if
   C_TEXT($MethodName_T)
   $MethodName_T:=Current method name
    //===================== Declare Variables ==================================
    //method_parameters_declarations
   C_TEXT($1;$2)
   C_BOOLEAN($3)
   C_BOOLEAN($0)
    //--------------------------------------------------------------------------------
    //method_wide_constants_declarations
    //--------------------------------------------------------------------------------
    //local_variable_declarations
   C_LONGINT($Ndx;$SOA;$RIS;$procState;$procTime;$procNumber)
   C_TEXT($methodName;$newProcName;$currentProcName)
   C_BOOLEAN($go;$ForceNewProcess_b)

End if
//====================== Initialize and Setup ================================

$methodName:=$1
$newProcName:=$2

If (Count parameters=3)
   $ForceNewProcess_b:=$3
Else
   $ForceNewProcess_b:=False
End if

PROCESS PROPERTIES(Current process;$currentProcName;$procState;$procTime)

//======================== Method Actions ==================================

Case of
   : ($ForceNewProcess_b)
      If ($newProcName#$currentProcName) // This is not in its own process
         $procNumber:=New process($methodName;64*1024;$newProcName)
         BRING TO FRONT($procNumber)
         $go:=False

      Else
         $go:=True

      End if

   : ($newProcName#$currentProcName) // This is not in its own process
      $procNumber:=New process($methodName;64*1024;$newProcName;*)
      BRING TO FRONT($procNumber)
      $go:=False

Else
   $go:=True

End case

//======================== Clean up and Exit =================================

$0:=$go



Open the calling method into a new process given the name of the calling method and open a new window.

If (Shell_SelfStart ($MethodName_T;$ProcName_T))

   ALL RECORDS([myTable])

   $Ndx:=Open form window("myForm_d";\
   Plain form window;\
   Horizontally centered;\
   Vertically centered)
   DIALOG("myForm_d")
   CLOSE WINDOW($Ndx)

End if