Datalab Functions for FastReport

Datalab Functions for FastReport
In this appendix the most important functions for FastReport written specially for PANTHEON are described in short. They are sorted alphabetically.
CallQRBeforeBandPrint
The procedure CallQRBeforeBandPrint calls program code in Pantheon written for this band. It is written in the band's event OnBeforePrint.
Procedure header:
procedure CallQRBeforeBandPrint(Sender: TfrxComponent; var PrintBand: Boolean);
Example
procedure TitleOnBeforePrint(Sender: TfrxComponent);
begin
CallQRBeforeBandPrint(Sender, TfrxBand(sender).visible);
end;
DATALAB Academy | Curriculum PANTHEON X – FastReport
dlBoolToYesNo
The function dlBoolToYesNo returns 'Yes' if the parameter value is True otherwise it returns 'No'.
Function header:
function dlBoolToYesNo(bCondition: Boolean): String;
Example
On service statement printouts it prints whether an item is under warranty.
[dlBoolToYesNo(<qReportIzpis."anWarrenty"> = 'T')]
dlDiv
The function dlDiv returns the quotient of two numbers if the second parameter doesn’t equal 0. If the second parameters equals 0, it returns 0.
Function header:
function dlDiv(nNum1, nNum2: Real): Real;
Example
[dlDiv(<qReportIzpis."anQty">, <qReportIzpis."anUMToUM2">)]
2
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
dlDpaExecute
The function dlDpaExecute runs an Ares applet (DPA).
Function header:
procedure dlDpaExecute(cKey: String);
Example
dlDpaExecute('A000042');
dlGetCurrentUserID and dlGetCurrentUserName
The function dlGetCurrentUserID returns the current user’s ID.
The function dlGetCurrentUserName returns the current user’s name.
Function headers:
function dlGetCurrentUserID: String;
function dlGetCurrentUserName: String;
3
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
Example
[dlGetCurrentUserID] - [dlGetCurrentUserName]
dlGetKeyViewFromKey
The function dlGetKeyViewFromKey converts unformatted document numbers to a formatted one depending on control panel settings.
Function header:
function dlGetKeyViewFromKey(cKey: String);
Example
[dlGetKeyViewFromKey(<qReportIzpis."acKey">)]
dlGetPostCode
The function dlGetPostCode returns the postal code without a prefix or postfix.
Function header:
function dlGetPostCode(cKey: String);
4
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
Example
[dlGetPostCode(<qReportIzpis1."acPost">)]
dlGetSaldoStr
The function dlGetSaldoStr converts the number in notation into the character D (meaning debit) or C (meaning credit) at the end. It is used in the
Demeter (Finance) module.
If the first parameter is greater than 0, it returns the first parameter and the character D at the end.
If the first parameter is smaller than 0, it returns the absolute value of the first parameter, and the character C at the end.
If the first parameter is 0 and the second parameter is B, it returns the text 'BALANCED'.
If the first parameter is 0 and the second parameter is NOT B, it returns the second parameter.
Function header:
function dlSaldoStr(nSaldo: Currency; cStr: String): String;
Example
[dlSaldoStr(nSaldo,'0')]
[dlSaldoStr(SUM(<qReportIzpis."anDebit"> - <qReportIzpis."anCredit">),'B')]
5
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
dlGetTempDirectory
The function dlGetTempDirectory returns the temporary Windows directory. This is convenient when working with files because it is the only folder in
which writing and reading files is always possible.
Function header:
function dlGetTempDirectory: String;
Example
Windows temporary directory: [dlGetTempDirectory]
dlLoadCompanyImage
The procedure dlLoadCompanyImage loads your company logo defined in the control panel into a picture object on printout.
Procedure header:
procedure dlLoadCompanyImage(Picture: TfrxPictureView);
Example
Put the picture object named Picture1 onto an arbitrary printout and write the event OnBeforePrint:
procedure Picture1OnBeforePrint(Sender: TfrxComponent);
6
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
begin
dlLoadCompanyImage(Picture1);
end;
dlLoadProductImage
The procedure dlLoadProductImage loads an item's logo defined in the items register into a picture object on printout.
Procedure header:
procedure dlLoadProductImage(Picture: TfrxPictureView; cIdent: String);
Example
Put the picture object named Picture1 onto an arbitrary printout and write the event OnBeforePrint:
procedure Picture1OnBeforePrint(Sender: TfrxComponent);
begin
dlLoadProductImage(Picture1, <qReportIzpis."acIdent">);
end;
dlLoadUserSignature
The procedure dlLoadUserSignature loads the user's signature defined in the subjects register into a picture object on printout.
Procedure header:
procedure dlLoadUserSignature(Picture: TfrxPictureView; cIdent: String);
7
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
Example
To show the current user's signature, put the picture object named Picture1 onto an arbitrary printout and write the event OnBeforePrint:
procedure Picture1OnBeforePrint(Sender: TfrxComponent);
begin
dlLoadUserSignature(Picture1, < dlGetCurrentUserID>);
end;
To show the signature of signer 1 on invoice printout, put the picture object named Picture1 onto the printout and write the event OnBeforePrint.
procedure Picture3OnBeforePrint(Sender: TfrxComponent);
begin
dlLoadUserSignature(Picture3,<qReportIzpisD."anSigner1">);
end;
dlNumberInWords
The function dlNumberInWords returns numbers in words.
The first function parameter is a number (monetary value).
The second parameter is currency.
The third parameter is the language in which text should be returned. If the third parameter is empty, the text function returns the result in the language of
the program. If the language does not exist, it returns empty text.
Function header:
function dlNumberInWords(nNumber: Currency; cCurrency, cLanguage: String): String;
8
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
Example
Print in English regardless of the program language: thousand EUR 00/100:
[dlNumberInWords(1000,'EUR','EN')]
Print the text for payment on invoices when issuing goods in the program’s language:
[dlNumberInWords(<qReportIzpisD."anForPay">, <qReportIzpisD."acCurrency">, '')]
Print the text for payment in English regardless of the program language:
[dlNumberInWords(dlTextToFloat(fZaPlacilo.Text), <qReportIzpisD."acCurrency">, 'EN')]
dlQuotedStr
The procedure dlQuotedStr imitates the Delphi function QuotedStr for solving cases where quotation marks (') exist in data text.
Procedure header:
procedure dlQuotedStr(Str: String): String;
Example
SQLExp('select acCode from tHE_SetItemExtItemSubj where acSubject = ' +
dlQuotedStr(<qReportIzpis."acSubject">) + ' ')
9
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
dlStringReplace
The function dlStringReplace imitates the Delphi function StringReplace. The difference is that flags are written as strings instead of option elements. If
options are not used, empty strings must be used.
flags
rfReplaceAll – change all found strings, otherwise change only the first appearance of text.
rfIgnoreCase – do not distinguish lowercase and uppercase letters.
Function header:
function dlStringReplace(const S, OldPattern, NewPattern: String; Flags1, Flag2: String): String;
Example
On balance printouts, where activity codes can be written with a point (for example 15.110) or without it (for example15110), the point will be deleted if it
exists.
[dlStringReplace(<qReportIzpis2."acActivityCode">,'.','','rfReplaceAll','')]
dlStrToFloatDef
The function dlStrToFloatDef converts text to decimal numbers. If the conversion fails, it returns the second parameter.
Function header:
function dlStrToFloatDef(S: String; Default: Extended): Extended;
10
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
Example
[dlStrToFloatDef(SQLExp('select SUM(anAmount) from tHE_SADCost where acKey = ''' + <qReportIzpis."acKey">
+ ''''), 0)]
dlStrToIntDef
The function dlStrToIntDef converts text to integers. If the conversion fails, it returns the second parameter.
Function header:
function dlStrToIntDef(S: String; Default: Integer): Integer;
Example
[dlStrToIntDef(FormatDateTime('d',<qReportIzpis."adDateDue">),0)]
dlTextToFloat
The function dlTextToFloat converts text with thousand separators to decimal numbers. If the conversion fails, it returns 0.
Header functions:
function dlTextToFloat(S: String): Extended;
11
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
Example
Print the exact amount without thousand separator on invoices when issuing goods.
[dlTextToFloat(fTrosarina.Text)]
ExtractMonth i Extract Week
The function ExtractMonth returns the month of a specified date in the form of a number.
The function ExtractWeek returns the week of a specified date in the form of number.
Function headers:
function ExtractMonth(Date: TDate): String;
function ExtractWeek(Date: TDate): String;
Example
Current month and week.
[ExtractMonth(DATE)]
[ExtractWeek(DATE)]
12
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
GetFormValue
The function GetFormValue returns the value of the object in the PANTHEON window. The parameter is the object name including the PANTHEON
window on which it is placed. If the object doesn’t exist or it is not created, it returns empty text.
Function header:
function GetFormValue(FormComponentName: String): Variant;
Example
Print the value in the editbox for the item code in stock as of the date of the printout:
[GetFormValue('PrometIzpisTrenZaloga.fIdent')]
SQLExp
The function SQLExp returns the SQL statement result executed on the database.
Function header:
function SQLExp(sql: String): String;
13
 2016 in whole or by parts Datalab Academy. All rights reserved.
DATALAB Academy | Curriculum PANTHEON X – FastReport
Example
Our company city:
[SQLExp('select dbo.fHE_GetOurCompanyCity()')]
Our company second name:
[SQLExp('select S.acName2 from tHE_SetSubj S, tPA_SysParam P where S.acSubject = P.acOurCompany')]
14
 2016 in whole or by parts Datalab Academy. All rights reserved.