using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WhitePage.Data;
namespace TestDbfRecord
{
class Program
{
static void Main(string[] args)
{
//NEW DbfFieldType
//USING EVAL
//create table
List<DbfFieldInfo> fields = new List<DbfFieldInfo>();
fields.Add( new DbfFieldInfo("nickname", DbfFieldType.Character ,100 ));
fields.Add( new DbfFieldInfo("note", DbfFieldType.Memo, 0));
fields.Add(new DbfFieldInfo("DT", 'D', 8, 0));
fields.Add(new DbfFieldInfo("NUM", 'N', 6, 2));
fields.Add(new DbfFieldInfo("LOGI", 'L', 1, 0));
DbfFieldInfo field = new DbfFieldInfo();
field = new DbfFieldInfo();
field.Name = "note";
field.Type = DbfFieldType.Memo;
fields.Add(field);
string file = AppDomain.CurrentDomain.BaseDirectory +"\\demo.dbf";
using (DbfRecordset rs = DbfRecordset.Create(file, fields))
{
eval(rs, "iif(1+1 > 2 , .T. , .F.)");
eval(rs, ".t. and .t.");
eval(rs, ".t. .and. .t.");
eval(rs, ".t. .or. .F.");
eval(rs, "-1");
eval(rs, "--1");
eval(rs, "---1");
eval(rs, "----1 + -2");
eval(rs, "! .t. ");
eval(rs, "not .t. ");
eval(rs, ".not. .t. ");
eval(rs, "'abc' == 'abc'");
eval(rs, "'abc' == 'ab'");
eval(rs, "'abc' > 'ab'");
eval(rs, " 200.92 >= 1000.23433");
eval(rs, " 200.92 != 1000.23433");
eval(rs, " 'nick' $ 'i'");
eval(rs, " 'i' $ 'nick'");
eval(rs, "UPPER('qwerty')");
eval(rs, "str(100.23) + str(12.34)");
eval(rs, "'[' + str(12.344, 10) + ']'");
eval(rs, "'[' + str(12.344, 10,2) + ']'");
eval(rs, "right('1234567',3)");
eval(rs, "left('1234567',3)");
eval(rs, "QUARTER(CTOD('11/12/2012'),1)");
eval(rs, "day(CTOD('11/12/2012'))");
eval(rs, "month(CTOD('11/12/2012'))");
eval(rs, "CTOD('11/12/2012')");
eval(rs, "STOD('20120131')");
eval(rs, "empty('20120131')");
eval(rs, "empty('')");
eval(rs, "trim(' rwytuwyrt ')");
eval(rs, "ltrim(' rwytuwyrt ')");
eval(rs, "alltrim(' rwytuwyrt ')");
eval(rs, "'[' + padR('123',10) + ']'");
eval(rs, "'[' + padR('123',10,'W') + ']'");
eval(rs, "'[' + padL('123',10) + ']'");
eval(rs, "'[' + padL('123',10,'W') + ']'");
eval(rs, "soundex('word')");
eval(rs, "len('word')");
eval(rs, "val('12.34')");
eval(rs, "abs(-12.34)");
Random ran = new Random(1000);
int recCount = 10;
for (int i = 1; i <= recCount; i++)
{
int id = ran.Next(0,1000);
string nick = "Jon ID :" + id.ToString();
System.Diagnostics.Debug.Print(nick);
rs.AddNew(); // append black
rs["nickname"] = nick;
rs.Update(); // commit changes
}
rs.ForEach(r =>
{
eval(r, "substr(nickname,2,2) + upper(nickname)");
return false; // only once
});
rs.Close();
}
}
static void eval(DbfRecordset rs, string expr)
{
object value = rs.Eval(expr);
System.Diagnostics.Debug.Print( expr + " : " + value.ToString() );
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WhitePage.Data;
namespace TestDbfRecord
{
class Program
{
static void Main(string[] args)
{
//NEW DbfFieldType
//USING EVAL
//create table
List<DbfFieldInfo> fields = new List<DbfFieldInfo>();
fields.Add( new DbfFieldInfo("nickname", DbfFieldType.Character ,100 ));
fields.Add( new DbfFieldInfo("note", DbfFieldType.Memo, 0));
fields.Add(new DbfFieldInfo("DT", 'D', 8, 0));
fields.Add(new DbfFieldInfo("NUM", 'N', 6, 2));
fields.Add(new DbfFieldInfo("LOGI", 'L', 1, 0));
DbfFieldInfo field = new DbfFieldInfo();
field = new DbfFieldInfo();
field.Name = "note";
field.Type = DbfFieldType.Memo;
fields.Add(field);
string file = AppDomain.CurrentDomain.BaseDirectory +"\\demo.dbf";
using (DbfRecordset rs = DbfRecordset.Create(file, fields))
{
eval(rs, "iif(1+1 > 2 , .T. , .F.)");
eval(rs, ".t. and .t.");
eval(rs, ".t. .and. .t.");
eval(rs, ".t. .or. .F.");
eval(rs, "-1");
eval(rs, "--1");
eval(rs, "---1");
eval(rs, "----1 + -2");
eval(rs, "! .t. ");
eval(rs, "not .t. ");
eval(rs, ".not. .t. ");
eval(rs, "'abc' == 'abc'");
eval(rs, "'abc' == 'ab'");
eval(rs, "'abc' > 'ab'");
eval(rs, " 200.92 >= 1000.23433");
eval(rs, " 200.92 != 1000.23433");
eval(rs, " 'nick' $ 'i'");
eval(rs, " 'i' $ 'nick'");
eval(rs, "UPPER('qwerty')");
eval(rs, "str(100.23) + str(12.34)");
eval(rs, "'[' + str(12.344, 10) + ']'");
eval(rs, "'[' + str(12.344, 10,2) + ']'");
eval(rs, "right('1234567',3)");
eval(rs, "left('1234567',3)");
eval(rs, "QUARTER(CTOD('11/12/2012'),1)");
eval(rs, "day(CTOD('11/12/2012'))");
eval(rs, "month(CTOD('11/12/2012'))");
eval(rs, "CTOD('11/12/2012')");
eval(rs, "STOD('20120131')");
eval(rs, "empty('20120131')");
eval(rs, "empty('')");
eval(rs, "trim(' rwytuwyrt ')");
eval(rs, "ltrim(' rwytuwyrt ')");
eval(rs, "alltrim(' rwytuwyrt ')");
eval(rs, "'[' + padR('123',10) + ']'");
eval(rs, "'[' + padR('123',10,'W') + ']'");
eval(rs, "'[' + padL('123',10) + ']'");
eval(rs, "'[' + padL('123',10,'W') + ']'");
eval(rs, "soundex('word')");
eval(rs, "len('word')");
eval(rs, "val('12.34')");
eval(rs, "abs(-12.34)");
Random ran = new Random(1000);
int recCount = 10;
for (int i = 1; i <= recCount; i++)
{
int id = ran.Next(0,1000);
string nick = "Jon ID :" + id.ToString();
System.Diagnostics.Debug.Print(nick);
rs.AddNew(); // append black
rs["nickname"] = nick;
rs.Update(); // commit changes
}
rs.ForEach(r =>
{
eval(r, "substr(nickname,2,2) + upper(nickname)");
return false; // only once
});
rs.Close();
}
}
static void eval(DbfRecordset rs, string expr)
{
object value = rs.Eval(expr);
System.Diagnostics.Debug.Print( expr + " : " + value.ToString() );
}
}
}