How can i change a variable value?
theodore
Greece
Hello
I need to use a variable for a report, then pass it to the report. After that the report has to change the value of that variable and after report printing to access the changed value of the variable.
Can i do that and how?
I know how to pass and use the variable, i tried changing the value of the variable by putting in an obp event looking like variable:=12345, with the variable name without brackets. I can see the changed value by referencing the variable on a memo using [variable] but when back in program the variable value seems unchanged
Thanks
I need to use a variable for a report, then pass it to the report. After that the report has to change the value of that variable and after report printing to access the changed value of the variable.
Can i do that and how?
I know how to pass and use the variable, i tried changing the value of the variable by putting in an obp event looking like variable:=12345, with the variable name without brackets. I can see the changed value by referencing the variable on a memo using [variable] but when back in program the variable value seems unchanged
Thanks
Comments
in the report create a userfunction in an obp of the band or script of memo
ie myval := myuserfunctionname(p1,p2,p3); you can pass up to 3 parameters out to Delphi at once and it will return 1 result, which you can use or ignore
your parameters can be a variable datafield or a value just enclose in [] and separate with commas.
you also have to write an onuserfunction event handler for the report component itself in Delphi to handle the values passed out and set the return the value.
Create User function for the report component.
procedure TForm1.frReport1UserFunction(const Name: string; p1, p2,
p3: Variant; var Val: Variant);
var
s: string; // declare variables of required type.
i: int
d1: date
begin
if AnsiCompareText(Name, 'myuserfunctionname') = 0 then
begin
s:= frparser.calc(p1); //get value from report and stor in delphi variable
i:= frparser.calc(p2);
d1:= frparser.calc(p3);
code to parse and do whatever
val := whatever external delphi function(); // return result to report in val
end;
end;
you can also make use of the onprintreport event of the report component
it fires once each time a report is sent to the printer.
regards
2.25. How to pass a value to the report?
There are several methods to do this. First is to use global object
frVariables (defined in FR_Class unit):
frVariables := 10;
This code creates a new variable with 'My variable' name and value = 10.
This method is best to pass static data to the report.
(can I pass data from report to the program?)
Use frVariables object. If you write the following code in any script:
MyVariable := 10
then in your program you can use this code to retrieve MyVariable value:
v := frVariables;
Thanks....