Calculated Columns - Can I Declare Variables in Expressions

Hi,

Is it possible to declare ans use a variable in the expression of a calculated column?

Idea was something like:
Dim StockPrev as Integer;
StockPrev:=[EXIST.STKREAL]+[EXIST.QTDENCFOR]-[EXIST.QTDENCCLI]
II(StockPrev<[EXIST.STKREAL] or StockPrev<0),[EXIST.STKMIN]-StockPrev,0)

What i want to return is the result of IIF; but I would like to use variables to make several calculations before.

Thanks

Comments

  • edited 11:18PM
    read FRNetUserManual-en.pdf, script section and example, is that what you wanted?
  • edited 11:18PM
    ipong wrote: »
    read FRNetUserManual-en.pdf, script section and example, is that what you wanted?

    Not exactly: in this case I was looking at the possibility to do this at the data source level, in the expression of a Calculated Column.

    I can create a calculated Column named StkPrev, and assign the expression as:
    [EXIST.STKREAL]+[EXIST.QTDENCFOR]-[EXIST.QTDENCCLI]

    What I would like to know if I can declare and use variables at this level, or if the use of variables is reserved to the script level.






  • edited October 2016
    There are two methods for calculated columns :

    1. in textobject, the formula is enclosed by square brackets, create expression like this :

    EXIST.STKREAL] + [EXIST.QTDENCFOR] - [EXIST.QTDENCCLI


    2. use script, more flexible, with c# you can code anything :
    namespace FastReport
    {
      public class ReportScript
      {
        private decimal StkPrev;
    
        private void Data1_BeforePrint(object sender, EventArgs e)
        {
          StkPrev = (Decimal)Report.GetColumnValue("EXIST.STKREAL") + (Decimal)Report.GetColumnValue("EXIST.QTDENCFOR") - (Decimal)Report.GetColumnValue("EXIST.QTDENCCLI");
        }
      }
    }
    </ScriptText>
    

    then create textobject with expression [StkPrev] , variable StkPrev in script can be used as an expression in textobject.

Leave a Comment