Multiple Application Instances Using Rave

Category

Rave - General

Question

I need to run multiple instances of my application, each of which uses Rave. When I try and do this I get errors. What do I need to do to enable this to work?

Solution

The reason errors are being generated is because the separate applications' direct data view groups are colliding. If you need to run multiple programs with separate reporting direct data view groups, set RPDefine.DataID to a unique value and the separate apps will not collide. Setting the DataID value needs to be done prior to executing any reports. It is recommended that you do this in the OnCreate event of your main form and use something that will be unique to the application.

Delphi Example:

procedure TForm1.FormCreate(Sender: TObject);
begin
  RPDefine.DataID := IntToStr(HInstance);
end;

C++Builder Example:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Rpdefine::DataID = IntToStr(HInstance);  
}

1-March-2003: Multiple Application Instances, Revisited

There have been a number of recent reports of problems using the code provided above. First, it is critical that the DataID variable be set before any Rave connections have been created. Also, tests with Delphi 7 indicate that, for reasons not clear at this time, using the main form HInstance variable does not necessarily provide a value different for each instance of the application.

The currently recommended way of setting the DataID variable is to place the code in the project's .DPR file and to use the application handle:

Delphi Example:

begin
  RPDefine.DataID := IntToStr(Application.Handle);
  Application.Initialze;
  {etc...}
end;

You'll need to add RPDefine and Sysutils to the DPR file's USES clause.