I use fast report 4.15 in delphi xe2, How can I use Expression in Value when report get value event?

Example:

I have one MemoView in report with Text "[a]" and GetValue event of report is:

procedure TForm1.rep1GetValue(const VarName: string; var Value: Variant);
begin
  if VarName = 'a' then
    Value := 'first with [b] item'
  else if VarName = 'b' then
    Value := 'second';
end;

I want report: "first with second item".

Example 2:

in report i have one TfrxMemoView with text "[MyExp]",
in form is one EditBox with Name "edt1" which user can write text to this.

GetValue event of report is :

procedure TForm1.rep1GetValue(const VarName: string; var Value: Variant);
begin
  if(VarName = 'a1') then
    Value:= 'item 1'
  else if VarName = 'a2' then
    Value:= 'item 2'
  else if VarName = 'a3' then
    Value:= 'item 3'
  else if VarName = 'a4' then
    Value:= 'item 4'
  else if VarName = 'a5' then
    Value:= 'item 5'
  else if VarName = 'a6' then
    Value:= 'item 6'
  else if VarName = 'MyExp' then
    Value:= edt1.Text;
end;

Now : if i write in edt1 : "show [a2] ok" , then i want frxReport write "show item 2 ok" in frxMemoView.
if i write in edt1 : "show [a5] ok" , then i want frxReport write "show item 5 ok" in frxMemoView.
...

有帮助吗?

解决方案 2

I found my answer :

if name of frxMemoView is Memo1 then in main block of report code write :

Memo1.Text:= <MyExp>;

其他提示

Taking your question literally, this is how you can solve it with a recursive call to the function:

procedure TForm1.rep1GetValue(const VarName: string; var Value: Variant);
var
  Temp: Variant;
begin
  if VarName = 'a' then
  begin
    // Call the function with 'a' and get the Value into the Temp variable
    rep1GetValue('b', Temp);

    // Assemble the resulting value
    Value := 'first with ' + Temp + ' item'
  end
  else if VarName = 'b' then
    Value := 'second';
end;

Unless further clarification of what you want to achieve - I can't answer any better.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top