Install/Test DBD DLL with C/C++

Steps to install and test the DBD DLL with Visual C++.
1. Download DLL appropriate for your OS and save in C:\Temp\Test directory.
2. Expand
3. Run Microsoft VC++
4. From menu File > New, select "Win32 Console Application" in Projects Tab.
Set Project name to "Test".
Set location to "C:\Temp\Test".
Click OK.
5. Select "A simple application" and click Finish.
6. Copy dbd.dll, dbd.lib and dbd.h into C:\Temp\Test
7. Update your Test.cpp to be similar (if not equivalent) to that shown below.
8. For Windows NT, 2000 and XP environments, from MS VC++'s menu > Project > Setting > C/C++ Tab > In 'Preprocessor definitions' text box, remove "_MBCS" add "UNICODE,_UNICODE" and click OK.
9. From menu > Project > Setting > Link Tab > In 'Object/library modules' text box, add " dbd.lib" and click OK.
10. In Workspace Window which list project files, in File View Tab, right-click 'Header Files' Folder select 'Add Files to Folder'. In dialog box, select dbd.h and click OK.
11. Build project.
12. Single-step (F10) thru code and verify error codes returned by functions are 0.
Single-step thru code three more times to execute all sections.
13. Exit VC++.
14. Verify data in C:\Temp\Test\Db1.dbd with dbd.exe
15. To uninstall, delete folder C:\Temp\Test
// Test.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "dbd.h"
#include "stdio.h"

int main(int argc, char* argv[])
  int errCode = Db_FileSpec_set_r(_T("Db1.dbd"));

  if (!Db_File_exists_b()){
    // ****************************************
    // * This code is executed during 1st run *

    // Create db file
      errCode = Db_File_create_r(kDbSzDef_g);

    // Open db file
      errCode = Db_File_open_r();

    // Create gender
      Xp_process_r(_T("(new 'gender)"));

    // Create a person named john and set his gender to male
      Xp_process_r(_T("(new 'john 'person)"));
      Xp_process_r(_T("(set+ john gender 'male)"));

    // Create a person named mary and set her gender to female
      Xp_process_r(_T("(new 'mary 'person)"));
      Xp_process_r(_T("(set+ mary gender 'female)"));
    // Open db file
      errCode = Db_File_open_r();

    // If bob is missing in db
      int* pBob = AStr_getNamed(_T("bob"));
      if (!pBob){
        // *******************************************
        // * This is code is executed during 2nd run *

        // Create age
          Xp_process_r(_T("(new 'age)"));

        // Create a person named bob
        // Set his gender to male and age to 35
          Xp_process_r(_T("(new 'bob 'person)"));
          Xp_process_r(_T("(set+ bob gender 'male)"));
          Xp_process_r(_T("(set+ bob age '35)"));

        // Set john's age to 30 
          Xp_process_r(_T("(set+ john age '30)"));

        // Get all person that are male
        // Following prints john and bob
          int* pQry = Xp_compile(
            _T("(and (get person instance *) (get * gender male))"));
          while (int* pPersonX=Xp_execute(pQry)){
              TCHAR sName[kStrSz_g+1] = _T("");
              N_Name_get(pPersonX, sName, kStrSz_g);
              wprintf(_T("%s\n"), sName);
          int* pBuild = AStr_getNamed(_T("build"));
          if (!pBuild){
            // *******************************************
            // * This is code is executed during 3nd run *

            // Create body build 
              Xp_process_r(_T("(new 'build)"));

            // Set bob's build to tall
              Xp_process_r(_T("(set+ bob build 'tall)"));

            // Set mary's build to thin and petite
              Xp_process_r(_T("(set+ mary build 'thin)"));
              Xp_process_r(_T("(set+ mary build 'petite)"));
            int* pSue = AStr_getNamed(_T("sue"));
            if (!pSue){
              // *******************************************
              // * This is code is executed during 4th run *
              // It uses low-level methods

              // Create a person named sue
                pSue = N_create();
                int* pPerson = AStr_getNamed(_T("person"));
                N_SVO_set(pPerson, pInst_g, pSue);
                int* pStrSue = AStr_getStr(_T("sue"), TRUE);
                N_SVO_set(pSue, pName_g, pStrSue);

              // Set sue's gender to female
                int* pGender = AStr_getNamed(_T("gender"));
                int* pFemale = AStr_getNamed(_T("female"));
                N_SVO_set(pSue, pGender, pFemale);

              // Set sue's age to 21
                int* pAge = AStr_getNamed(_T("age"));
                int* pStr21 = AStr_getStr(_T("21"), TRUE);
                int* pAge21 = N_ClsInst_get(pAge, pStr21, TRUE);
                N_SVO_set(pSue, pAge, pAge21);

              // Set sue's build to fat and short
                N_EA_setV_wAStr(pSue, pBuild, _T("fat"));
                N_EA_setV_wAStr(pSue, pBuild, _T("short"));

              // Change john's age from 30 to 40
                int* pJohn = AStr_getNamed(_T("john"));
                int* pStr30 = AStr_getStr(_T("30"), TRUE);
                int* pAge30 = N_ClsInst_get(pAge, pStr30, TRUE);
                int* pStr40 = AStr_getStr(_T("40"), TRUE);
                int* pAge40 = N_ClsInst_get(pAge, pStr40, TRUE);
                N_SV_changeO(pJohn, pAge, pAge30, pAge40);

              // Delete mary's build is thin
                int* pMary = AStr_getNamed(_T("mary"));
                int* pThin = AStr_getNamed(_T("thin"));
                int* pSVO = N_SVO_get(pMary, pBuild, pThin);

  // * This is code is executed during all runs *
  // Print each person's attributes and values

  // During 1st run, prints:
  //   john gender male
  //   mary gender female
  // During 2nd run, prints:
  //   john gender male
  //   john age 30
  //   mary gender female
  //   bob gender male
  //   bob age 35

  // During 3rd run, prints:
  //   john gender male
  //   john age 30
  //   mary gender female
  //   mary build thin
  //   mary build petite
  //   bob gender male
  //   bob age 35
  //   bob build tall

  // During 4th run, prints:
  //   john gender male
  //   john age 40
  //   mary gender female
  //   mary build petite
  //   bob gender male
  //   bob age 35
  //   bob build tall
  //   sue gender female
  //   sue age 21
  //   sue build fat
  //   sue build short

    int* pQry = Xp_compile(_T("(get person instance *)"));
    while (int* pPtX=Xp_execute(pQry)){
      int* pA[256]; int* p = (int*)pA;
      int* eS = Xp_Node(pPtX, p);
      int* eSVO = Xp_S_getSVO(eS, p);
      while (int* pSVO=Xp_execute(eSVO)){
        int* pSub = N_SVO_getElem(pSVO, kSeqSub_g);
        int* pVb = N_SVO_getElem(pSVO, kSeqVb_g);
        int* pObj = N_SVO_getElem(pSVO, kSeqObj_g);
        if (pVb != pName_g){
          // Print "person attribute value"
            TCHAR sEntity[kStrSz_g+1] = _T("");
            N_Name_get(pSub, sEntity, kStrSz_g);

            TCHAR sProp[kStrSz_g+1] = _T("");
            N_Name_get(pVb, sProp, kStrSz_g);

            TCHAR sVal[kStrSz_g+1] = _T("");
            N_Name_get(pObj, sVal, kStrSz_g);

            wprintf(_T("%s %s %s\n"), sEntity, sProp, sVal);

  return 0;
The creation of rolex replica the watch is inspired by the retro and elegant money of rolex replica watches the brand's round watch. The chronograph is omega replica simple and stylish, with the line features of rolex replica uk the watch series.

CM ©2000-2007