home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
bufop.zip
/
TESTPC.CPP
< prev
next >
Wrap
Text File
|
1993-09-06
|
2KB
|
92 lines
#include <iostream.h>
#include "tsta.hpp"
class printTest : public IIterator<testCls> {
public:
virtual Boolean applyTo(testCls & p)
{ cout << p << "\n\n "; return True;}
};
int main(void)
{
testCls a;
startit(); // start the database (in tsta)
a.create("Sally Smith", "101 Main st", 35, 101);
a.create("Fred Mac", "111 South North Ave", 46, 102);
a.create("Ed Ross" ,"1625 Red Mill",42,103);
a.create("Mary Smith", "1122 three st", 12,104);
a.create("George Garcia", "789 ten ave", 55, 105);
a.create("Darrell Crandel","101 nowhere",42,106);
a.create("Catherine Michell", "Rt 45",12,107);
a.create("Debra Jose","121 North",38,108);
a.read(101);
cout << a;
a.changeAge(34);
a.update();
a.read(102);
cout << a;
a.read(101);
cout << a;
//
// test the ability to read directly into a structure
//
stest * myStruct = new stest; // create a new structure
readDB(myStruct);
//
// these next examples require the IBM C/Set ++ & collection classes
//
//
// read a set of items based on dynamic selection (well - dynamic to
// the SQL engine)
//
printTest printit; // a class to print the elements
selectTest b;
nameSet setA;
b.setSelect("ID > 103"); // get all records with ID > 3
setA << b;
cout << " Every one with a record ID > 103 \n";
setA.allElementsDo(printit);
setA.removeAll(); // clean up
b.setSelect("age < 35");
cout << " All records with age < 35 ";
setA << b;
setA.allElementsDo(printit);
setA.removeAll();
b.setSelect("name like 'D%' ");
setA << b;
cout << "all records with the name starting with D \n";
setA.allElementsDo(printit);
//
// turn off the database and exit
//
stopit(); // stop using the database (in tsta)
return 0;
}