⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 todo2.c

📁 palm的pocketc
💻 C
字号:
// ToDo reader
int i, nRecs, rc;
pointer todo;

main() {
  // allocate memory for the data
  todo = malloct(1, "iiss");
  
  // attempt to open the database
  if (!dbopen("ToDoDB")) {
    puts("Unable to open ToDo database");
    return;
  }

  // read and display all records
  nRecs = dbnrecs();
  puts("NumRecs: " + nRecs + "\n");
  for (i=0;i<nRecs;i++) {
    dbrec(i);
    rc = dbreadx(todo, "i2cszsz");
    // if rc != 4, then this is not a valid record
    // and has probably been deleted
    if (rc==4) {
      puts("Record: "+i+"\n  Priority: "+todo[1]+"\n  Title: "
        + todo[2] + "\n  Note: " + todo[3] + "\n");
    }
  }

  // add a new record
  todo[0] = 0xffff; // no category, date
  todo[1] = 4; // priority = 4
  todo[2] = "Register PocketC"; // text
  todo[3] = "PocketC, from OrbWorks costs only $18.50.\nOrder you copy today!";
  dbrec(-1); // new record
  rc = dbwritex(todo, "i2cszsz");
  if (rc != 4)
     puts("Error creating new todo!");
  
  // close the database
  dbclose();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -