Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

Debuging RAP code

edited June 2005 in RAP
Is it possible do debug the RAP code? I mean, as we use F7/F8, watches
in Delphi, I could use these resources in my report code. Is it possible?
When we have a big report (many lines of code) it is a little hard do
find errors and check the variables. I'm using ShowMessage at the code
to check the varibles values but it is to much boring to do this..

Thanks.
Gilvan Justino

Comments

  • edited June 2005
    Hi Gilvan,

    Unfortunately there is no debugger included with RAP. If you would like to
    debug your RAP code you have two options...

    1. Use CodeSite by Raize Software (http://www.raize.com). There is an
    example of integrating CodeSite with RAP located in the \RBuilder\Demos\0.
    RAP\2. CodeSite\... directory.

    2. Place "ShowMessage" commands in your RAP code to find out certain values
    during execution.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited September 2005
    I have added a file logging function to my RAP code. The following is the
    Delphi code:

    class function TLogMessageFunction.GetSignature: String;
    begin
    Result := 'function LogMessage(Report: TppReport; msg: string): boolean;';
    end;

    procedure TLogMessageFunction.ExecuteFunction(aParams: TraParamList);
    var
    lReport: TppReport;
    lMessage: string;
    lResult: boolean;
    FFile: TextFile;
    FName: string;
    begin
    GetParamValue(0, lReport);
    GetParamValue(1, lMessage);
    if lReport.Template.SaveTo = stFile then
    //drop the .rtm from the filename and add .log
    FName :=
    copy(lReport.Template.FileName,0,length(lReport.Template.FileName) - 4) +
    '.log'
    else
    begin
    //db templates
    //get config settings from xml file, like the default log path, etc.,
    since there's no path to use
    GetConfigSettings;
    FName := IncludeTrailingBackslash(GlobalPath) +
    lReport.Template.DatabaseSettings.Name + '.log';
    end;//if lReport.Template.SaveTo
    try
    AssignFile(FFile, FName);
    if FileExists(FName) then
    Append(FFile)
    else
    Rewrite(FFile);
    WriteLn(FFile,FormatDateTime('dd mmm yyyy hh:nn:ss.zzz',NOW) + ': ' +
    lMessage);
    CloseFile(FFile);
    lResult := True;
    except
    lResult := False;
    end;//try..except
    SetParamValue(2,lResult);
    end; {TmyGetDelphiComponentFunction.ExecuteFunction}

    class function TLTRIMFunction.HasParams: Boolean;
    begin
    Result := True;
    end;

    The following is how it's used in RAP:

    procedure Log(msg: string);
    begin
    //debugmode is a global boolean variable
    //that can easily be turned on/off to allow logging
    if DebugMode then
    LogMessage(Report,msg);
    end;

    procedure ReportBeforePrint;
    begin
    Log('Entered ReportBeforePrint');
    ...
    Log('myDataView[''myColumn''] : ' + myDataView['myColumn']);
    ...
    Log('Variable x: ' + IntToStr(x));
    ...
    Log('Exited ReportBeforePrint');
    end;

    We use it to log entry/exit of all methods. If there's a problem w/ a
    method, the log will show the entry, but not the exit. Then, it's just a
    matter of adding additional logging to determine exactly where it's hanging.

    Thanks,
    Paul

  • edited September 2005

    Thanks for sharing this! :)

    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.