How to store Memo value in script

edited 3:04AM in FastReport 4.0
Hi,

I've been using FastReport for a while now, and am somewhat surprised I have not had to do this before. I am trying to store a numerical value (integer) in a memo field via Pascal Script (code). Historically I have never had a problem capturing a value or even using it in calculations (IE reading back a value from a memo field). However I see that whenever I have done this, I have either put the value directly into the memo field (IE not via script code) such as:
[frxDB2."NS Vol In"]

or via calculation such as:
[<frxDB2."NS Vol In"> + <frxDB2."AM Vol In"> + <frxDB2."PM Vol In">]

In my script, I can read these values back, eg X := Memo1.Value + 10; however when I try to write or assign a value to the memo field (eg Memo1.Value := 10) I get told that Memo1 cannot be assigned to.

I can however write text to the field, such as Memo1.Memo.Text := '10', but if I try to read this back, I get null back (which makes sense, as I have assigned a text string, not a value to the memo field).

What am I doing wrong? Why can I assign a numerical value inside the memo field itself in the report editor, but not via Pascal script code?

Comments

  • gpigpi
    edited June 2017
    Use
    Memo1.Memo.Text := '10';
    X := StrToInt(Memo1.Memo.Text) + 10;
    
  • edited June 2017
    gpi wrote: »
    Use
    Memo1.Memo.Text := '10';
    X := StrToInt(Memo1.Memo.Text) + 10;
    

    Thanks. I found another way which I tend to prefer, as it results in a memo actually containing a numerical value as required. IF you surround the textual value with square brackets, it then responds as a value, IE
    Memo1.Memo.Text := '[25]'
    X := 2 * Memo1.Value

    The above results in an answer of X = 50 (and no errors). Likewise, when the report is viewed, the memo field containing [25] presents as 25 (IE brackets are not visible) which makes sense. The only caveat I have found so far is this technique does not work if I use an "on after print" event (at least that appears to be the case). IE if I do something like if Engine.FinalPass then Memo105.Memo.Text := '[25]'; will result in square brackets being visible, and the characters being treated as text as opposed to a number.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.