Sample Delphi code that makes a Delphi app wait till ReportSmith's Runtime Viewer is ready for another command.

procedure TForm1.Button1Click(Sender: TObject);
var
  TheData: PChar;
  PSetup : PChar;
  s : string;
begin

{ This block of code causes the Runtime to display its "Print Setup" dialog box. }
s := 'ExecuteMenu "File|Print Setup"';
PSetup := StrAlloc(Length(s));
StrPCopy(PSetup, s);
  { DdeService is set to RS_Runtime, and }
  { DdeTopic is set to Command.  }
DdeClientConv1.ExecuteMacro(PSetup, false);
StrDispose(PSetup);

{ This is the block of code that makes Delphi wait until the Runtime Viewer is ready for another command. }
TheData :=nil;			{ Clear the variable. }
s := '';			{ Clear the variable. }
while s <> 'Ready' do		{ Loop until s = 'Ready' }
begin
  { DdeService is set to RS_Runtime, and }
  { DdeTopic is set to System.  }
  { 'Status' is a ReportSmith DDE Item.  It returns Ready when RS is not busy.}
  TheData := DdeClientConv2.RequestData('Status'); { The method allocates memory. }
  if TheData <> nil then
  begin
    s := StrPas(TheData);
    Label1.Caption := StrPas(TheData); { This line is only to see what's being returned. }
  end;
  StrDispose(TheData);   { On-line help says to dispose of requested data. }
end;

Report1.Run;		{ Now, Runtime is ready for its next task.  }
Report1.CloseReport(false);

end;
