Page 1 of 1

Calling R&R reports from Delphi

Posted: Mon Feb 14, 2011 9:45 pm
by Bruce
Hi,____I am starting a new project using Delphi 2007 and R&R 12.5 (having used R&R for the past 20 years interfacing via control files and xbase++)____I have read the documentation and created a very simple test to run one report. However, I am unable to get R&R to run the report within Delphi.____My test code is:____procedure TForm1.Button3Click(Sender: TObject);__var__// var for error__lpszMsg: PChar; //PInteger; //PAnsiChar;__mSize: Integer;__lpiCode: PInteger; // PAnsiChar;__Ertn: LongBool; //PChar;____// for choosereport__RepHandle: integer;__AppName: Pchar;__LibName: Pchar;__LSize: Integer;__Rep: Pchar;__RSize: Integer;__//ReportReturnCode: integer;__bWait: Boolean;__FsCmdShow: integer;__RptErrMsg: PAnsiChar;__lpiECode: PInteger;__lplPageCount: PLongInt;__emSize: integer;__RtnBol: LongBool;____begin__lpszMsg:= ^^;__mSize:= 200;__lpiCode:= 0;__//__AppName := nil;__LibName := nil;__LSize := 0;__Rep := ^c:devedm2000 rwards.rrw^;__Rsize := 40;__//__emSize := 200;__bWait := true;__//RtnBol:=false;__FsCmdShow:= 0;__RptErrMsg:=^^;__lpiECode:=nil;__lplPageCount:=nil;____// Start R&R routine__resetErrorInfo(0); // clears the error buffer____RepHandle:= chooseReport(AppName,LibName,LSize,Rep,RSize);__// Check for errors__ getErrorInfo(RepHandle,lpszMsg,mSize,lpiCode);__// Set runtime settings here...__RtnBol := execRuntime(RepHandle,bWait,FsCmdShow,lpiECode,lplPageCount,RptErrMsg,emSize);__Ertn := getErrorInfo(RepHandle,lpszMsg,mSize,lpiCode);__if RtnBol then__begin;__ showmessage(^Report returned True^)__end____else;____begin;__ showmessage(^Report returned False: ^ + lpszMsg)__ // now need to GetError to see what is wrong__ GetErrorInfo();____end;____end;____I must be missing basic but as I have never done this before with R&R I am at a loss to determine where I am going wrong.____Can anyone please help with this? (Just a short snippet from some working code may just show me what I have wrong).____Best regards,____Bruce____PS: Word wrap on this posting may split some lines.________

=> RE: Calling R&R reports from Delphi

Posted: Mon Feb 21, 2011 9:48 pm
by kfleming
Why not call the rrwrun.exe executable directly as an alternative?____Kathleen__R&R Support

==> RE: Calling R&R reports from Delphi

Posted: Fri Feb 25, 2011 10:37 am
by Bruce
Kathleen,____This is what I do for my xbase++ applications but I am trying to avoid shelling out to a separate exe and writing separate runtime files. The dll functionality would be very tidy and contained within one r& dll and one application exe. It would facilitate easier error control within my main application.____Do you not have a basic sample file for Delphi to use the dll?____Best regards,____Bruce______PS: One item for the wish list: On the print preview screen have an option to go to PDF or Word file as well as print. I know you can do this when you create the report but it would be so useful to have that option on print preview.

=> RE: Calling R&R reports from Delphi

Posted: Tue Mar 01, 2011 10:41 am
by Tom_Freitas_(Guest)
I am trying to get the code snippet you posted to work, but am getting an error on the chooseReport. ____GetErrorInfo is reporting an error code of 76 (L) and the error message is eight little squares. ____If the error code 76 corresponds to getErrorInfo code ^L^, I believe that is an error has to do with either the lpszLibName or lSize parameter. ____The report being called is not in a library. I have tried passing all sorts of different variations of empty, nil and null values as well as skipping the library name parameter and the size parameter altogether. ____How do I call chooseReport for a report that is not in a report library?____Thanks__Peter____

==> RE: Calling R&R reports from Delphi

Posted: Wed Mar 09, 2011 10:39 am
by Bruce
Has no one managed to run R&R reports from Delphi? If this is the case then I will need to review our use of R&R as a lot of our new projects are in Delphi and we need a reliable report generator.____Best regards,____Bruce

==> RE: Calling R&R reports from Delphi

Posted: Thu Mar 10, 2011 10:39 am
by Bruce
Kathleen,____You appear to censor the information on this forum to the detriment of assisting in providing a solution. However, I have had assistance from other sources and below is a working snippet of code for other to use:______procedure TForm1.Button3Click(Sender: TObject);__var__ RepHandle: integer;__ RtnBol: LongBool;____ bWait: Boolean;__ FsCmdShow: Integer;__ lpszEMsg: array[0..511] of char;__ lpiECode: Integer;__ lplPageCount: LongInt;____ pszAppName: PChar;__ lpszLibName: array[0..255] of char;__ lSize: Integer;__ lpszRepName: string;__ rSize: Integer;____ lpszMsg: array[0..511] of char;__ lpiCode: Integer;__ Ertn: LongBool;______begin__ FillChar(lpszLibName, SizeOf(lpszLibName), #0);__ FillChar(lpszMsg, SizeOf(lpszMsg), #0);__ FillChar(lpszEMsg, SizeOf(lpszEMsg), #0);____ // lpszRepName := ^c:\dev\edm2000\rr\ward.rrw^; // Either format works fine.__ lpszRepName := ^c:devedm2000 rward.rrw^;____ bWait := true;__ FsCmdShow:= 0;__ lplPageCount := 0;__ lpiECode := 0;____ // Start R&R routine__ resetErrorInfo(0); // clears the error buffer____ RepHandle := chooseReport(nil, @lpszLibName[0], SizeOf(lpszLibName),__ PChar(lpszRepName), Length(lpszRepName));______ // Set runtime settings here...__ RtnBol := execRuntime(RepHandle, bWait, FsCmdShow, @lpiECode, @lplPageCount,__ @lpszEMsg[0], SizeOf(lpszEMsg));____ if RepHandle = 0 then__ begin__ // Check for errors__ getErrorInfo(RepHandle, @lpszMsg[0], SizeOf(lpszMsg), @lpiCode);__ //do something with the returned error code__ showmessage(^Report encountered an error: ^ + string(lpszMsg) + ^, lpicode: ^ + string(@lpiCode) );__ Exit;__ end__ else__ begin__ showmessage(^Report ran successfully^);__ end__ end;____I would suggest that this type of information is made available in your documentation so that other can use your product more widely. R&R is a very powerful report tool and has more functionality that Crystal (IMHO).____Best regards,____Bruce__

==> RE: Calling R&R reports from Delphi

Posted: Thu Mar 24, 2011 5:08 pm
by Bruce
Delphi is very much like dBase if I am not mistaken! Like Kathleen says, you can call it from the program by using the rrwrunin.dbf file as you command report file or calling the report itself directly. If you use the rrwrunin.dbf file, and say this report is line 3 in the rrwrunin.dbf file.____The command would simply be run(.t.,"rrwrun.exe rrwrunin.dbf 3")____If you decide to call the report up directly, then it would be run(.t.,"rrwrun.exe reportname.rrw")____Remember to put the quotes around the command.____You can also assign variables instead.______Tom Freitas

===> RE: Calling R&R reports from Delphi

Posted: Tue Apr 24, 2012 9:54 am
by Peter
Tom - thank you for the suggestion. This is what I do in xbase++ but as the new application was using Delphi and SQL I wanted to leave the dbf files and call directly from the DLL. The sample code I posted later permits me to do this.____Best regards,____Bruce__