Example #1
0
        /// <summary>
        /// Get the function that is stored in the scope.
        /// </summary>
        /// <param name="scope"></param>
        /// <param name="realName"></param>
        /// <returns></returns>
        public static QsFunction GetFunction(QsScope scope, string qsNamespace, string functionName)
        {
            if (string.IsNullOrEmpty(qsNamespace))
            {
                // no namespace included then it is from the local scope.


                // I am adding the mathmatical functions in the root namespace
                // so I will test for the function namespace and

                QsFunction function = (QsFunction)MathNamespace.GetValueOrNull(functionName);

                // built int math functions will be overwrite any other functions
                if (function != null)
                {
                    return(function);
                }
                else
                {
                    function = (QsFunction)QsEvaluator.GetScopeValueOrNull(scope, qsNamespace, functionName);
                }

                return(function);
            }
            else
            {
                try
                {
                    QsNamespace ns = QsNamespace.GetNamespace(scope, qsNamespace);


                    return((QsFunction)ns.GetValue(functionName));
                }
                catch (QsVariableNotFoundException)
                {
                    return(null);
                }
            }
        }
Example #2
0
    /// <summary>
    /// List Command
    /// </summary>
    internal static void ListVariables()
    {
        Console.WriteLine();
        Console.ForegroundColor = ValuesColor;

        foreach (string var in GetVariablesKeys())
        {
            var v = GetVariable(var);
            Console.WriteLine("    " + var + " = " + v.ToString());
            if (v is QsNamespace)
            {
                QsNamespace ns = (QsNamespace)v;
                foreach (string nsvar in ns.GetVariablesKeys())
                {
                    Console.WriteLine("        " + nsvar + " = " + ns.GetValue(nsvar).ToString());
                }
            }
            Console.WriteLine();
        }

        Console.ForegroundColor = ForegroundColor;
        Console.WriteLine();
    }