Chip,

The technique that Dave Batton used in Foundation (and released publicly in
a couple of free components) went like this:

Start most methods with a call to the INIT method:

Eg.

 // ----------------------------------------------------
  // Project Method: Log_Init

  // Initializes both the process and interprocess variables used by
  // the logging routines.

  // Access: Private

  // Parameters: None

  // Returns: Nothing

  // Created by Dave Batton on May 25, 2004
  // ----------------------------------------------------

C_BOOLEAN(<>Log_Initialized_b; Log_Initialized_b)


If (Not(<>Log_Initialized_b))  // So we only do this once.
Compiler_Log

//  Do Application wide initialisation here
End if

If (Not(Log_Initialized_b))  // So we only do this once.
Compiler_Log

//  Do process wide initialisation here
End if

The Compiler method would look like this:

  // ----------------------------------------------------
  // Project Method: Compiler_Log

  // Compiler variables related to the Foundation Log routines.

  // Access: Private

  // Parameters: None

  // Returns: Nothing

  // Created by Dave Batton on Jul 26, 2003
  // ----------------------------------------------------

  // Interprocess Variables
C_BOOLEAN(<>Log_Initialized_b)
If (Not(<>Log_Initialized_b))   // So we only do the IP variables once per
application launch
// Declare all IP vars here
C_TEXT(<>Log_Path_t;<>Log_RecordDelimiter_t)
C_LONGINT(<>Log_Platform_i)

End if

  // Process Variables
C_BOOLEAN(Log_Initialized_b)
If (Not(Log_Initialized_b))   // So we only do the process variables once
per process
// Declare all process vars here
ARRAY TEXT(Log_Messages_at;0)

End if

  // Parameters
If (False)  // So we never run this as code.
C_TEXT(Log_AddEntry ;${1})

C_BOOLEAN(Log_Enable ;$0;$1)

C_TEXT(Log_FileName ;$0;$1)

C_TEXT(Log_Info ;$0;$1)

C_TEXT(Log_Path ;$0)

C_LONGINT(Log_PositionR ;$0)
C_TEXT(Log_PositionR ;$1;$2)
End if

Since then we now have a new database method: On Host Database Event
database method

This was introduced in v14 and you can initialise your component here, as
well as starting any methods/processes automatically.

http://doc.4d.com/4Dv14/4D/14.4/On-Host-Database-Event-database-method.301-2511007.en.html

The _Init method still works of course.



Regards,

Wayne


[image: --]
Wayne Stewart
[image: http://]about.me/waynestewart
<http://about.me/waynestewart>


On 29 April 2017 at 04:17, Chip Scheide via 4D_Tech <[email protected]>
wrote:

> do I need to initialize the component's IP, or process variables in
> every process or just once at startup of the host database?
>
> Thanks
> Chip
> ---------------
> Gas is for washing parts
> Alcohol is for drinkin'
> Nitromethane is for racing
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to