Example #1
0
		/// <summary>
		/// obtain value of Textbox
		/// </summary>
		public FunctionTextbox(Textbox tb, string uniquename) 
		{
			t=tb;
			if (uniquename == null)	
				return;
			// We need to register this expression with the Textbox
			tb.AddExpressionReference(uniquename);
		}
Example #2
0
        Visibility _Visibility; // Indicates if the group (and all groups embedded

        #endregion Fields

        #region Constructors

        internal TableGroup(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            _Grouping=null;
            _Sorting=null;
            _Header=null;
            _Footer=null;
            _Visibility=null;
            _ToggleTextbox=null;

            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "Grouping":
                        _Grouping = new Grouping(r, this, xNodeLoop);
                        break;
                    case "Sorting":
                        _Sorting = new Sorting(r, this, xNodeLoop);
                        break;
                    case "Header":
                        _Header = new Header(r, this, xNodeLoop);
                        break;
                    case "Footer":
                        _Footer = new Footer(r, this, xNodeLoop);
                        break;
                    case "Visibility":
                        _Visibility = new Visibility(r, this, xNodeLoop);
                        break;
                    default:
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown TableGroup element '" + xNodeLoop.Name + "' ignored.");
                        break;
                }
            }
            if (_Grouping == null)
                OwnerReport.rl.LogError(8, "TableGroup requires the Grouping element.");
        }
Example #3
0
        Visibility _Visibility; // Indicates if the details should be hidden

        #endregion Fields

        #region Constructors

        internal Details(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            _TableRows=null;
            _Grouping=null;
            _Sorting=null;
            _Visibility=null;
            _ToggleTextbox = null;

            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "TableRows":
                        _TableRows = new TableRows(r, this, xNodeLoop);
                        break;
                    case "Grouping":
                        _Grouping = new Grouping(r, this, xNodeLoop);
                        break;
                    case "Sorting":
                        _Sorting = new Sorting(r, this, xNodeLoop);
                        break;
                    case "Visibility":
                        _Visibility = new Visibility(r, this, xNodeLoop);
                        break;
                    default:
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown Details element " + xNodeLoop.Name + " ignored.");
                        break;
                }
            }
            if (_TableRows == null)
                OwnerReport.rl.LogError(8, "Details requires the TableRows element.");
        }
		internal void AddHideDuplicates(Textbox tb)
		{
			if (_HideDuplicates == null)
                _HideDuplicates = new List<Textbox>();
			_HideDuplicates.Add(tb);
		}
Example #5
0
        public void Textbox(Textbox tb, string t, Row row)
        {
            if (tb.IsHtml(this.r, row))
            {                                   // just do escape chars > 128?
                t = RtfAnsi(t);
            }
            else
            {
                // make all the characters readable
                t = EscapeText(t);
            }
            // determine if we're in a tablecell
            bool bCell = InTable(tb);

            if (t != "")
            {
                tw.Write("{");
                DoStyle(tb.Style, row);
                tw.Write(t);
                tw.Write("}");
            }
            if (bCell)
                tw.Write(@"\cell");
        }
Example #6
0
		internal object LastObject=null;	// last object calculated

		static internal TextboxRuntime GetTextboxRuntime(Report rpt, Textbox tb)
		{
			TextboxRuntime tbr = rpt.Cache.Get(tb, "txtbox") as TextboxRuntime;
			if (tbr != null)
				return tbr;
			tbr = new TextboxRuntime();
			rpt.Cache.Add(tb, "txtbox", tbr);
			return tbr;
		}
Example #7
0
		public void Textbox(Textbox tb, string t, Row row)
		{
			if (!tb.IsHtml(this.r, row))		// we leave the text as is when request is to treat as html
			{									//   this can screw up the generated HTML if not properly formed HTML
				// make all the characters browser readable
				t = XmlUtil.XmlAnsi(t);

				// handle any specified bookmark
				t = Bookmark(tb.BookmarkValue(this.r, row), t);

				// handle any specified actions
				t = Action(tb.Action, row, t, tb.ToolTipValue(this.r, row));
			}
			// determine if we're in a tablecell
			Type tp = tb.Parent.Parent.GetType();
			bool bCell;
			if (tp == typeof(TableCell) ||
				tp == typeof(Corner) ||
				tp == typeof(DynamicColumns) ||
				tp == typeof(DynamicRows) ||
				tp == typeof(StaticRow) ||
				tp == typeof(StaticColumn) ||
				tp == typeof(Subtotal) ||
				tp == typeof(MatrixCell))
				bCell = true;
			else
				bCell = false;

			if (tp == typeof(Rectangle))
				tw.Write("<td>");

			if (bCell)
			{	// The cell has the formatting for this text
				if (t == "")
					tw.Write("<br />");		// must have something in cell for formating
				else
					tw.Write(t);
			}
			else
			{	// Formatting must be specified
				string cssName = CssAdd(tb.Style, tb, row);	// get the style name for this item

				tw.Write("<div class='{0}'>{1}</div>", cssName, t);
			}

			if (tp == typeof(Rectangle))
				tw.Write("</td>");
		}
        public override void Textbox(Textbox tb, string t, Row row)
        {
            base.Textbox(tb, t, row);
            bool tableCell = IsTableCell(tb);
            if (!tableCell)
            {
                if (_currentRow == null || _currentRow != tb.Top.PixelsY)
                {
                        _currentRow = tb.Top.PixelsY;
                        _writer.WriteStartElement(new DocumentFormat.OpenXml.Spreadsheet.Row()); //new row
                }

            }

            int? idCellFormat = GetStyleIndex(tb.Style, row, ref t);

            if (idCellFormat != null)
            {

                var attributes = new OpenXmlAttribute[] { new OpenXmlAttribute("s", null, idCellFormat.ToString()) }.ToList();
              //  if (tb.Width!=null)
              //      attributes.Add(new OpenXmlAttribute("width", null, Measurement.PointsToExcelUnits(tb.Width.Points).ToString()));
                if ((IsNumeric(t) || IsNumeric(t, CultureInfo.CurrentCulture)))
                    _openXmlExportHelper.WriteCellValueSax(_writer, t, CellValues.Number, attributes);
                else
                    _openXmlExportHelper.WriteCellValueSax(_writer, t, CellValues.InlineString, attributes);
            }
            else
                _openXmlExportHelper.WriteCellValueSax(_writer, t, CellValues.InlineString);

            if (!tableCell)
            {
                _writer.WriteEndElement();
                _currentWorkSheet.NextRow();
            }
        }
Example #9
0
        List<ReportItem> _Items; // list of report items

        #endregion Fields

        #region Constructors

        internal ReportItems(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            ReportItem ri;
            _Items = new List<ReportItem>();

            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "Rectangle":
                        ri = new Rectangle(r, this, xNodeLoop);
                        break;
                    case "Line":
                        ri = new Line(r, this, xNodeLoop);
                        break;
                    case "Textbox":
                        ri = new Textbox(r, this, xNodeLoop);
                        break;
                    case "Image":
                        ri = new Image(r, this, xNodeLoop);
                        break;
                    case "Subreport":
                        ri = new Subreport(r, this, xNodeLoop);
                        break;
                    // DataRegions: list, table, matrix, chart
                    case "List":
                        ri = new List(r, this, xNodeLoop);
                        break;
                    case "Table":
                    case "Grid":
                    case "fyi:Grid":
                        ri = new Table(r, this, xNodeLoop);
                        break;
                    case "Matrix":
                        ri = new Matrix(r, this, xNodeLoop);
                        break;
                    case "Chart":
                        ri = new Chart(r, this, xNodeLoop);
                        break;
                    case "ChartExpression":		// For internal use only
                        ri = new ChartExpression(r, this, xNodeLoop);
                        break;
                    case "CustomReportItem":
                        ri = new CustomReportItem(r, this, xNodeLoop);
                        break;
                    default:
                        ri=null;		// don't know what this is
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown ReportItems element '" + xNodeLoop.Name + "' ignored.");
                        break;
                }
                if (ri != null)
                {
                    _Items.Add(ri);
                }
            }
            if (_Items.Count == 0)
                OwnerReport.rl.LogError(8, "At least one item must be in the ReportItems.");
            else
                _Items.TrimExcess();
        }
		override internal void FinalPass()
		{
			if (_Grouping != null)
				_Grouping.FinalPass();
			if (_Sorting != null)
				_Sorting.FinalPass();
			if (_Header != null)
				_Header.FinalPass();
			if (_Footer != null)
				_Footer.FinalPass();
			if (_Visibility != null)
			{
				_Visibility.FinalPass();
				if (_Visibility.ToggleItem != null)
				{
					_ToggleTextbox = (Textbox) (OwnerReport.LUReportItems[_Visibility.ToggleItem]);
					if (_ToggleTextbox != null)
						_ToggleTextbox.IsToggle = true;
				}
			}
			return;
		}
Example #11
0
        List <ReportItem> _Items;                                       // list of report items

        internal ReportItems(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
        {
            ReportItem ri;

            _Items = new List <ReportItem>();

            // Loop thru all the child nodes
            foreach (XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (xNodeLoop.Name)
                {
                case "Rectangle":
                    ri = new Rectangle(r, this, xNodeLoop);
                    break;

                case "Line":
                    ri = new Line(r, this, xNodeLoop);
                    break;

                case "Textbox":
                    ri = new Textbox(r, this, xNodeLoop);
                    break;

                case "Image":
                    ri = new Image(r, this, xNodeLoop);
                    break;

                case "Subreport":
                    ri = new Subreport(r, this, xNodeLoop);
                    break;

                // DataRegions: list, table, matrix, chart
                case "List":
                    ri = new List(r, this, xNodeLoop);
                    break;

                case "Table":
                case "Grid":
                case "fyi:Grid":
                    ri = new Table(r, this, xNodeLoop);
                    break;

                case "Matrix":
                    ri = new Matrix(r, this, xNodeLoop);
                    break;

                case "Chart":
                    ri = new Chart(r, this, xNodeLoop);
                    break;

                case "ChartExpression":                                 // For internal use only
                    ri = new ChartExpression(r, this, xNodeLoop);
                    break;

                case "CustomReportItem":
                    ri = new CustomReportItem(r, this, xNodeLoop);
                    break;

                default:
                    ri = null;                                          // don't know what this is
                    // don't know this element - log it
                    OwnerReport.rl.LogError(4, "Unknown ReportItems element '" + xNodeLoop.Name + "' ignored.");
                    break;
                }
                if (ri != null)
                {
                    _Items.Add(ri);
                }
            }
            if (_Items.Count == 0)
            {
                OwnerReport.rl.LogError(8, "At least one item must be in the ReportItems.");
            }
            else
            {
                _Items.TrimExcess();
            }
        }
Example #12
0
 public void Textbox(Textbox tb, string t, Row row)
 {
 }
Example #13
0
 protected internal bool IsTableCell(Textbox tb)
 {
     Type tp = tb.Parent.Parent.GetType();
     return (tp == typeof(TableCell) ||
         tp == typeof(Corner) ||
         tp == typeof(DynamicColumns) ||
         tp == typeof(DynamicRows) ||
         tp == typeof(StaticRow) ||
         tp == typeof(StaticColumn) ||
         tp == typeof(Subtotal) ||
         tp == typeof(MatrixCell));
 }
Example #14
0
        public void Textbox(Textbox tb, string t, Row r)
        {
            object value = tb.Evaluate(report, r);

            tw.Write(value);
        }
Example #15
0
 public void Textbox(Textbox tb, string t, Row row)
 {
     if (InTable(tb))
         _Excel.SetCell(_ExcelRow, _ExcelCol, t, GetStyle(tb, row));
     else if (InList(tb))
     {
         _ExcelCol++;
         _Excel.SetCell(_ExcelRow, _ExcelCol, t, GetStyle(tb, row));
     }
 }
Example #16
0
 public void Textbox(Textbox tb, string t, Row r)
 {
     object value = tb.Evaluate(report, r);
     tw.Write(value);
 }
Example #17
0
        public void Textbox(Textbox tb, string t, Row row)
        {
            if (tb.DataElementOutput != DataElementOutputEnum.Output ||
                tb.DataElementName == null)
                return;

            if (rowstart != null)		// In case no items in row are visible
            {							//   we delay until we get one.
            //				WriteElement(rowstart);
                rowstart = null;
            }
            t = XmlUtil.XmlAnsi(t);
            if (tb.DataElementStyle == DataElementStyleEnum.AttributeNormal)
            {	// write out as attribute
                WriteAttribute(" {0}='{1}'",
                                tb.DataElementName, XmlUtil.EscapeXmlAttribute(t));
            }
            else
            {	// write out as element
                WriteElement("<{0}>{1}</{0}>", tb.DataElementName, t);
            }
        }
Example #18
0
		private string SortType(TableCell tc, Textbox tb)
		{
			// return of null means don't sort
			if (tb == null || !IsTableSortable(tc.OwnerTable))
				return null;

			// default is true if table is sortable;
			//   but user may place override on Textbox custom tag
			if (tb.Custom != null)
			{
				// Loop thru all the child nodes
				foreach(XmlNode xNodeLoop in tb.Custom.CustomXmlNode.ChildNodes)
				{
					if (xNodeLoop.Name == "HTML")
					{
						if (xNodeLoop.LastChild.InnerText.ToLower() == "false")
						{
							return null;
						}
						break;
					}
				}
			}

			// Must find out the type of the detail column
			Details d = tc.OwnerTable.Details;
			if (d == null)
				return null;
			TableRow tr = d.TableRows.Items[0] as TableRow;
			if (tr == null)
				return null;
			TableCell dtc = tr.TableCells.Items[tc.ColIndex] as TableCell;
			if (dtc == null)
				return null;
			Textbox dtb = dtc.ReportItems.Items[0] as Textbox;
			if (dtb == null)
				return null;

			string sortcmp;
			switch (dtb.Value.Type)
			{
				case TypeCode.DateTime:
					sortcmp = "sort_cmp_date";
					break;
				case TypeCode.Int16:
				case TypeCode.UInt16:
				case TypeCode.Int32:
				case TypeCode.UInt32:
				case TypeCode.Int64:
				case TypeCode.UInt64:
				case TypeCode.Decimal:
				case TypeCode.Single:
				case TypeCode.Double:
					sortcmp = "sort_cmp_number";
					break;
				case TypeCode.String:
					sortcmp = "sort_cmp_string";
					break;
				case TypeCode.Empty:	// Not a type we know how to sort
				default:		
					sortcmp = null;
					break;
			}

			return sortcmp;
		}
Example #19
0
 public void Textbox(Textbox tb, string t, Row row)
 {
 }
Example #20
0
        // FuncIDent: IDENTIFIER ( [Expr] [, Expr]*) | IDENTIFIER
        private bool MatchFuncIDent(out IExpr result)
        {
            IExpr  e;
            string fullname;                                    // will hold the full name
            string method;                                      // will hold method name or second part of name
            string firstPart;                                   // will hold the collection name
            string thirdPart;                                   // will hold third part of name
            bool   bOnePart;                                    // simple name: no ! or . in name

            result = null;

            if (curToken.Type != TokenTypes.IDENTIFIER)
            {
                return(false);
            }

            // Disentangle method calls from collection references
            method   = fullname = curToken.Value;
            curToken = tokens.Extract();

            // Break the name into parts
            char[] breakChars = new char[] { '!', '.' };

            int posBreak = method.IndexOfAny(breakChars);

            if (posBreak > 0)
            {
                bOnePart  = false;
                firstPart = method.Substring(0, posBreak);
                method    = method.Substring(posBreak + 1);                     // rest of expression
            }
            else
            {
                bOnePart  = true;
                firstPart = method;
            }

            posBreak = method.IndexOf('.');
            if (posBreak > 0)
            {
                thirdPart = method.Substring(posBreak + 1);                     // rest of expression
                method    = method.Substring(0, posBreak);
            }
            else
            {
                thirdPart = null;
            }

            if (curToken.Type != TokenTypes.LPAREN)
            {
                switch (firstPart)
                {
                case "Fields":
                    Field f = idLookup.LookupField(method);
                    if (f == null && !this._InAggregate)
                    {
                        throw new ParserException("Field '" + method + "'  not found.");
                    }
                    if (thirdPart == null || thirdPart == "Value")
                    {
                        if (f == null)
                        {
                            FunctionField ff;
                            result = ff = new FunctionField(method);
                            this._FieldResolve.Add(ff);
                        }
                        else
                        {
                            result = new FunctionField(f);
                        }
                    }
                    else if (thirdPart == "IsMissing")
                    {
                        if (f == null)
                        {
                            FunctionField ff;
                            result = ff = new FunctionFieldIsMissing(method);
                            this._FieldResolve.Add(ff);
                        }
                        else
                        {
                            result = new FunctionFieldIsMissing(f);
                        }
                    }
                    else
                    {
                        throw new ParserException("Field '" + method + "'  only supports 'Value' and 'IsMissing' properties.");
                    }
                    return(true);

                case "Parameters":  // see ResolveParametersMethod for resolution of MultiValue parameter function reference
                    ReportParameter p = idLookup.LookupParameter(method);
                    if (p == null)
                    {
                        throw new ParserException("Report parameter '" + method + "'  not found.");
                    }
                    int ci = thirdPart == null? -1: thirdPart.IndexOf(".Count");
                    if (ci > 0)
                    {
                        thirdPart = thirdPart.Substring(0, ci);
                    }
                    FunctionReportParameter r;
                    if (thirdPart == null || thirdPart == "Value")
                    {
                        r = new FunctionReportParameter(p);
                    }
                    else if (thirdPart == "Label")
                    {
                        r = new FunctionReportParameterLabel(p);
                    }
                    else
                    {
                        throw new ParserException("Parameter '" + method + "'  only supports 'Value' and 'Label' properties.");
                    }
                    if (ci > 0)
                    {
                        r.SetParameterMethod("Count", null);
                    }

                    result = r;
                    return(true);

                case "ReportItems":
                    Textbox t = idLookup.LookupReportItem(method);
                    if (t == null)
                    {
                        throw new ParserException("ReportItem '" + method + "'  not found.");
                    }
                    if (thirdPart != null && thirdPart != "Value")
                    {
                        throw new ParserException("ReportItem '" + method + "'  only supports 'Value' property.");
                    }
                    result = new FunctionTextbox(t, idLookup.ExpressionName);
                    return(true);

                case "Globals":
                    e = idLookup.LookupGlobal(method);
                    if (e == null)
                    {
                        throw new ParserException("Globals '" + method + "'  not found.");
                    }
                    result = e;
                    return(true);

                case "User":
                    e = idLookup.LookupUser(method);
                    if (e == null)
                    {
                        throw new ParserException("User variable '" + method + "'  not found.");
                    }
                    result = e;
                    return(true);

                case "Recursive":                       // Only valid for some aggregate functions
                    result = new IdentifierKey(IdentifierKeyEnum.Recursive);
                    return(true);

                case "Simple":                          // Only valid for some aggregate functions
                    result = new IdentifierKey(IdentifierKeyEnum.Simple);
                    return(true);

                default:
                    if (!bOnePart)
                    {
                        throw new ParserException(string.Format("'{0}' is an unknown identifer.", fullname));
                    }

                    switch (method.ToLower())                                   // lexer should probably mark these
                    {
                    case "true":
                    case "false":
                        result = new ConstantBoolean(method.ToLower());
                        break;

                    default:
                        // usually this is enum that will be used in an aggregate
                        result = new Identifier(method);
                        break;
                    }
                    return(true);
                }
            }

            // We've got an function reference
            curToken = tokens.Extract();                        // get rid of '('

            // Got a function now obtain the arguments
            int argCount = 0;

            bool isAggregate = IsAggregate(method, bOnePart);

            if (_NoAggregate && isAggregate)
            {
                throw new ParserException("Aggregate function '" + method + "' cannot be used within a Grouping expression.");
            }
            if (_InAggregate && isAggregate)
            {
                throw new ParserException("Aggregate function '" + method + "' cannot be nested in another aggregate function.");
            }
            _InAggregate = isAggregate;
            if (_InAggregate)
            {
                _FieldResolve = new List <FunctionField>();
            }

            List <IExpr> largs = new List <IExpr>();

            while (true)
            {
                if (curToken.Type == TokenTypes.RPAREN)
                {                       // We've got our function
                    curToken = tokens.Extract();
                    break;
                }
                if (argCount == 0)
                {
                    // don't need to do anything
                }
                else if (curToken.Type == TokenTypes.COMMA)
                {
                    curToken = tokens.Extract();
                }
                else
                {
                    throw new ParserException("Invalid function arguments.  Found '" + curToken.Value + "'  At column " + Convert.ToString(curToken.StartCol));
                }

                MatchExprAndOr(out e);
                if (e == null)
                {
                    throw new ParserException("Expecting ',' or ')'.  Found '" + curToken.Value + "'  At column " + Convert.ToString(curToken.StartCol));
                }

                largs.Add(e);
                argCount++;
            }
            if (_InAggregate)
            {
                ResolveFields(method, this._FieldResolve, largs);
                _FieldResolve = null;
                _InAggregate  = false;
            }

            IExpr[] args = largs.ToArray();

            object scope;
            bool   bSimple;

            if (!bOnePart)
            {
                result = (firstPart == "Parameters")?
                         ResolveParametersMethod(method, thirdPart, args):
                         ResolveMethodCall(fullname, args); // throw exception when fails
            }
            else
            {
                switch (method.ToLower())
                {
                case "iif":
                    if (args.Length != 3)
                    {
                        throw new ParserException("iff function requires 3 arguments." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
//  We allow any type for the first argument; it will get converted to boolean at runtime
//					if (args[0].GetTypeCode() != TypeCode.Boolean)
//						throw new ParserException("First argument to iif function must be boolean." + "  At column " + Convert.ToString(curToken.StartCol));
                    result = new FunctionIif(args[0], args[1], args[2]);
                    break;

                case "choose":
                    if (args.Length <= 2)
                    {
                        throw new ParserException("Choose function requires at least 2 arguments." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    switch (args[0].GetTypeCode())
                    {
                    case TypeCode.Double:
                    case TypeCode.Single:
                    case TypeCode.Int32:
                    case TypeCode.Decimal:
                    case TypeCode.Int16:
                    case TypeCode.Int64:
                        break;

                    default:
                        throw new ParserException("First argument to Choose function must be numeric." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    result = new FunctionChoose(args);
                    break;

                case "switch":
                    if (args.Length <= 2)
                    {
                        throw new ParserException("Switch function requires at least 2 arguments." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    if (args.Length % 2 != 0)
                    {
                        throw new ParserException("Switch function must have an even number of arguments." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    for (int i = 0; i < args.Length; i = i + 2)
                    {
                        if (args[i].GetTypeCode() != TypeCode.Boolean)
                        {
                            throw new ParserException("Switch function must have a boolean expression every other argument." + "  At column " + Convert.ToString(curToken.StartCol));
                        }
                    }
                    result = new FunctionSwitch(args);
                    break;

                case "format":
                    if (args.Length > 2 || args.Length < 1)
                    {
                        throw new ParserException("Format function requires 2 arguments." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    if (args.Length == 1)
                    {
                        result = new FunctionFormat(args[0], new ConstantString(""));
                    }
                    else
                    {
                        if (args[1].GetTypeCode() != TypeCode.String)
                        {
                            throw new ParserException("Second argument to Format function must be a string." + "  At column " + Convert.ToString(curToken.StartCol));
                        }
                        result = new FunctionFormat(args[0], args[1]);
                    }
                    break;

                case "fields":
                    if (args.Length != 1)
                    {
                        throw new ParserException("Fields collection requires exactly 1 argument." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    result = new FunctionFieldCollection(idLookup.Fields, args[0]);
                    break;

                case "parameters":
                    if (args.Length != 1)
                    {
                        throw new ParserException("Parameters collection requires exactly 1 argument." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    result = new FunctionParameterCollection(idLookup.Parameters, args[0]);
                    break;

                case "reportitems":
                    if (args.Length != 1)
                    {
                        throw new ParserException("ReportItems collection requires exactly 1 argument." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    result = new FunctionReportItemCollection(idLookup.ReportItems, args[0]);
                    break;

                case "globals":
                    if (args.Length != 1)
                    {
                        throw new ParserException("Globals collection requires exactly 1 argument." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    result = new FunctionGlobalCollection(idLookup.Globals, args[0]);
                    break;

                case "user":
                    if (args.Length != 1)
                    {
                        throw new ParserException("User collection requires exactly 1 argument." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    result = new FunctionUserCollection(idLookup.User, args[0]);
                    break;

                case "sum":
                    scope = ResolveAggrScope(args, 2, out bSimple);
                    FunctionAggrSum aggrFS = new FunctionAggrSum(_DataCache, args[0], scope);
                    aggrFS.LevelCheck = bSimple;
                    result            = aggrFS;
                    break;

                case "avg":
                    scope = ResolveAggrScope(args, 2, out bSimple);
                    FunctionAggrAvg aggrFA = new FunctionAggrAvg(_DataCache, args[0], scope);
                    aggrFA.LevelCheck = bSimple;
                    result            = aggrFA;
                    break;

                case "min":
                    scope = ResolveAggrScope(args, 2, out bSimple);
                    FunctionAggrMin aggrFMin = new FunctionAggrMin(_DataCache, args[0], scope);
                    aggrFMin.LevelCheck = bSimple;
                    result = aggrFMin;
                    break;

                case "max":
                    scope = ResolveAggrScope(args, 2, out bSimple);
                    FunctionAggrMax aggrFMax = new FunctionAggrMax(_DataCache, args[0], scope);
                    aggrFMax.LevelCheck = bSimple;
                    result = aggrFMax;
                    break;

                case "first":
                    scope  = ResolveAggrScope(args, 2, out bSimple);
                    result = new FunctionAggrFirst(_DataCache, args[0], scope);
                    break;

                case "last":
                    scope  = ResolveAggrScope(args, 2, out bSimple);
                    result = new FunctionAggrLast(_DataCache, args[0], scope);
                    break;

                case "next":
                    scope  = ResolveAggrScope(args, 2, out bSimple);
                    result = new FunctionAggrNext(_DataCache, args[0], scope);
                    break;

                case "previous":
                    scope  = ResolveAggrScope(args, 2, out bSimple);
                    result = new FunctionAggrPrevious(_DataCache, args[0], scope);
                    break;

                case "level":
                    scope  = ResolveAggrScope(args, 1, out bSimple);
                    result = new FunctionAggrLevel(scope);
                    break;

                case "count":
                    scope = ResolveAggrScope(args, 2, out bSimple);
                    FunctionAggrCount aggrFC = new FunctionAggrCount(_DataCache, args[0], scope);
                    aggrFC.LevelCheck = bSimple;
                    result            = aggrFC;
                    break;

                case "countrows":
                    scope = ResolveAggrScope(args, 1, out bSimple);
                    FunctionAggrCountRows aggrFCR = new FunctionAggrCountRows(scope);
                    aggrFCR.LevelCheck = bSimple;
                    result             = aggrFCR;
                    break;

                case "countdistinct":
                    scope = ResolveAggrScope(args, 2, out bSimple);
                    FunctionAggrCountDistinct aggrFCD = new FunctionAggrCountDistinct(_DataCache, args[0], scope);
                    aggrFCD.LevelCheck = bSimple;
                    result             = aggrFCD;
                    break;

                case "rownumber":
                    scope = ResolveAggrScope(args, 1, out bSimple);
                    IExpr texpr = new ConstantDouble("0");
                    result = new FunctionAggrRvCount(_DataCache, texpr, scope);
                    break;

                case "runningvalue":
                    if (args.Length < 2 || args.Length > 3)
                    {
                        throw new ParserException("RunningValue takes 2 or 3 arguments." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    string aggrFunc = args[1].EvaluateString(null, null);
                    if (aggrFunc == null)
                    {
                        throw new ParserException("RunningValue 'Function' argument is invalid." + "  At column " + Convert.ToString(curToken.StartCol));
                    }
                    scope = ResolveAggrScope(args, 3, out bSimple);
                    switch (aggrFunc.ToLower())
                    {
                    case "sum":
                        result = new FunctionAggrRvSum(_DataCache, args[0], scope);
                        break;

                    case "avg":
                        result = new FunctionAggrRvAvg(_DataCache, args[0], scope);
                        break;

                    case "count":
                        result = new FunctionAggrRvCount(_DataCache, args[0], scope);
                        break;

                    case "max":
                        result = new FunctionAggrRvMax(_DataCache, args[0], scope);
                        break;

                    case "min":
                        result = new FunctionAggrRvMin(_DataCache, args[0], scope);
                        break;

                    case "stdev":
                        result = new FunctionAggrRvStdev(_DataCache, args[0], scope);
                        break;

                    case "stdevp":
                        result = new FunctionAggrRvStdevp(_DataCache, args[0], scope);
                        break;

                    case "var":
                        result = new FunctionAggrRvVar(_DataCache, args[0], scope);
                        break;

                    case "varp":
                        result = new FunctionAggrRvVarp(_DataCache, args[0], scope);
                        break;

                    default:
                        throw new ParserException("RunningValue function '" + aggrFunc + "' is not supported.  At column " + Convert.ToString(curToken.StartCol));
                    }
                    break;

                case "stdev":
                    scope = ResolveAggrScope(args, 2, out bSimple);
                    FunctionAggrStdev aggrSDev = new FunctionAggrStdev(_DataCache, args[0], scope);
                    aggrSDev.LevelCheck = bSimple;
                    result = aggrSDev;
                    break;

                case "stdevp":
                    scope = ResolveAggrScope(args, 2, out bSimple);
                    FunctionAggrStdevp aggrSDevP = new FunctionAggrStdevp(_DataCache, args[0], scope);
                    aggrSDevP.LevelCheck = bSimple;
                    result = aggrSDevP;
                    break;

                case "var":
                    scope = ResolveAggrScope(args, 2, out bSimple);
                    FunctionAggrVar aggrVar = new FunctionAggrVar(_DataCache, args[0], scope);
                    aggrVar.LevelCheck = bSimple;
                    result             = aggrVar;
                    break;

                case "varp":
                    scope = ResolveAggrScope(args, 2, out bSimple);
                    FunctionAggrVarp aggrVarP = new FunctionAggrVarp(_DataCache, args[0], scope);
                    aggrVarP.LevelCheck = bSimple;
                    result = aggrVarP;
                    break;

                default:
                    result = ResolveMethodCall(fullname, args);                                 // through exception when fails
                    break;
                }
            }

            return(true);
        }