# Initialize and Finalize

The `Initialize` procedure will be execute before any other events and can be used to initialize global variables.

Th `Finalize` procedure will called after the project is done and must be used to clear eventual gloabl objects created in the `Initialize` procedure

## Example

```objectpascal
var
  gDeler: TSearchTable; // Declare a gobale variable

procedure Initialize;
begin
  // The global variable has to created and initialized in the Initiliaze procedure
  gDeler := TSearchTable.Create('ALU_DELER'); // Create and load search table "ALU_DELER"
end;

procedure Finalize;
begin
  gDeler.Free; // The global variable has to be freed
end;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.calwincloud.com/calwin-script/machine-link/machine-link-events/initialize-and-finalize.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
