示例#1
0
 // Return type name as text
 public TextValue Type(TypedValue arg)
 {
     return(TextValue.Create(arg.DataType.ToString()));
 }
示例#2
0
        ///=================================================================
        ///
        /// Add-in functions
        ///

        // basic string
        public TextValue Text(TypedValue value)
        {
            return(TextValue.Create(value.ToString()));
        }
示例#3
0
 // fancier string
 public TextValue Format(TypedValue value)
 {
     return(TextValue.Create(value.Format()));
 }
示例#4
0
 // Import a linked or externally held relvar
 public VoidValue Import(TextValue sourcearg, TextValue namearg, TextValue whatarg, TextValue locatorarg)
 {
     if (sourcearg.Value == Catalog.DefaultDatabaseSource)
     {
         if (!_catvars.Catalog.LinkRelvar(namearg.Value))
         {
             throw ProgramError.Fatal("Connect", "cannot link to '{0}'", namearg.Value);
         }
     }
     else if (!_catvars.Catalog.ImportRelvar(sourcearg.Value, namearg.Value, whatarg.Value, locatorarg.Value))
     {
         throw ProgramError.Fatal("Connect", "cannot import from '{0}'", namearg.Value);
     }
     return(VoidValue.Default);
 }
示例#5
0
        // Match using regex
        public BoolValue Match(TextValue arg1, TextValue arg2)
        {
            Regex re = new Regex(arg2.Value);

            return(BoolValue.Create(re.IsMatch(arg1.Value)));
        }
示例#6
0
 // trigger an error
 public VoidValue Fail(TextValue source, TextValue message)
 {
     throw ProgramError.Fatal(source.Value, message.Value);
 }
示例#7
0
        public UserValue UserSelector(TextValue typename, TypedValue[] valargs)
        {
            var usertype = DataTypeUser.Find(typename.Value);

            return(usertype.CreateValue(valargs));
        }
示例#8
0
 public NumberValue Length(TextValue arg1)
 {
     return(NumberValue.Create(arg1.Value.Length));
 }
示例#9
0
        ///=================================================================
        /// Sequential IO
        ///

        // Write a text value to the console/output
        public VoidValue Write(TextValue line)
        {
            _output.WriteLine(line.Value);
            return(VoidValue.Default);
        }
示例#10
0
        // The part of arg1 after arg2, or nothing if not found
        public TextValue After(TextValue arg1, TextValue arg2)
        {
            int pos = arg1.Value.IndexOf(arg2.Value);

            return(pos == -1 ? TextValue.Default : TextValue.Create(arg1.Value.Substring(pos + arg2.Value.Length)));
        }
示例#11
0
 public TextValue ToLower(TextValue arg1)
 {
     return(TextValue.Create(arg1.Value.ToLower()));
 }
示例#12
0
        // The part of arg1 before arg2, or arg1 if not found
        public TextValue Before(TextValue arg1, TextValue arg2)
        {
            int pos = arg1.Value.IndexOf(arg2.Value);

            return(pos == -1 ? arg1 : TextValue.Create(arg1.Value.Substring(0, pos)));
        }
示例#13
0
 // remove leading and trailing white space
 public TextValue Trim(TextValue arg1)
 {
     return(TextValue.Create(arg1.Value.Trim()));
 }
示例#14
0
        ///=================================================================
        ///
        /// Text string operations
        ///

        // Concatenate. Converts arguments to string.
        public TextValue Concat(TypedValue arg1, TypedValue arg2)
        {
            return(TextValue.Create(arg1.ToString() + arg2.ToString()));
        }
示例#15
0
 public void SetText(int colno, string value)
 {
     _valueholder._values[colno] = TextValue.Create(value);
 }
示例#16
0
 static TextValue()
 {
     Default = new TextValue {
         Value = ""
     };
 }