📄 readme.txt
字号:
/////////////////////////////////////////////////////////////////////////
------------------- a file record set -----------------------
---------- this article was contributed by weedlee -----------
----------------- email: weedlee@mail.com --------------------
---------------------- 03/06/2000 ---------------------------
/////////////////////////////////////////////////////////////////////////
it's a simple class used to read and write records form a sigle file,
you can define your record struct in heard file and have some little change
in cpp file, then you can use it just like a record set.
1. source Files
header file: fileset.h
implementation file: fileset.cpp
class: cfileset
2. definition
modify header file such as:
a) your record struct
struct _DBRECORD
{
int NO;
unsigned char Name[11];
int Type;
long Value;
unsigned char Desc[51];
int DBNO;
int Addr;
};
b) your member variables binded with your record struct
// field member variables
int NO;
CString Name;
int Type;
long Value;
CString Desc;
int DBNO;
int Addr;
3. updatedata
modify implementation file such as:
void CFileSet::UpdateData(BOOL bUpdate)
{
if (bUpdate)
{
record.NO = NO; // position+1;
strcpy((char *)record.Name,LPCTSTR(Name));
record.Name[10] = 0;
record.Type = Type;
record.Value = Value;
strcpy((char *)record.Desc,LPCTSTR(Desc));
record.Desc[50] = 0;
record.DBNO = DBNO;
record.Addr = Addr;
}
else
{
NO = record.NO;
Name.Format("%s",record.Name);
Type = record.Type;
Value = record.Value;
Desc.Format("%s",record.Desc);
DBNO = record.DBNO;
Addr = record.Addr;
}
}
4. usage
such as:
...
CFileSet set;
set.Open("t2.dat");
while (!set.IsEOF())
{
// your code here
set.MoveNext();
}
set.Close();
...
you can use it just like a CRecordSet object
5. about enhanced functionality
it couldn't support primary key or index;
and it couldn't support sort also.
perhaps the next time i will add them.
6. thanks
it's very simple, perhaps you can enhanced it by yourself;
if your have any advice please email to me.
thank you.
================================= over ==================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -