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

        // basic string
        public TextValue Text(TypedValue value)
        {
            return(TextValue.Create(value.ToString()));
        }
Beispiel #3
0
 // fancier string
 public TextValue Format(TypedValue value)
 {
     return(TextValue.Create(value.Format()));
 }
Beispiel #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);
 }
Beispiel #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)));
        }
Beispiel #6
0
 // trigger an error
 public VoidValue Fail(TextValue source, TextValue message)
 {
     throw ProgramError.Fatal(source.Value, message.Value);
 }
Beispiel #7
0
        public UserValue UserSelector(TextValue typename, TypedValue[] valargs)
        {
            var usertype = DataTypeUser.Find(typename.Value);

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

        // Write a text value to the console/output
        public VoidValue Write(TextValue line)
        {
            _output.WriteLine(line.Value);
            return(VoidValue.Default);
        }
Beispiel #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)));
        }
Beispiel #11
0
 public TextValue ToLower(TextValue arg1)
 {
     return(TextValue.Create(arg1.Value.ToLower()));
 }
Beispiel #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)));
        }
Beispiel #13
0
 // remove leading and trailing white space
 public TextValue Trim(TextValue arg1)
 {
     return(TextValue.Create(arg1.Value.Trim()));
 }
Beispiel #14
0
        ///=================================================================
        ///
        /// Text string operations
        ///

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