OrbWorks

OrbForms Designer - Language and API

Home   [OrbForms Designer]   PocketC Architect   PocketC Palm OS   PocketC CE   Other  

Overview
Development Env.
Language/API
Download
Support Forum
Purchase
 

 

Language / API

The OrbC language is similar in style to C - using the same control constructs, expressions, and function style. The language supports four basic types (int, char, float, string), arrays, pointers, structs, objects, and interfaces. Although based on C, there are many differences that make the OrbC language easier to learn and use, and more efficient to work with.

Features

  • Four built-in data types: int, char, float, string, and pointers.
  • Supports all C statements: if, else, while, do, for, break, continue, switch, case, return
  • User defined structures
  • Simple objects (like structs with methods, including special methods: initializers, destructors, and copiers) 
  • Object inheritance with virtual methods
  • Interfaces
  • Handlers for UI/system events
  • Support for native add-ins

If you are familiar with PocketC, the OrbC language will be refreshingly similar but much more powerful - with the addition of structs, objects, interfaces, and new features such as compound assignment.

Handlers

Rather than creating a "main" function as with traditional C (and PocketC), using the OrbC language you define event handlers. For example, if you wanted to create an application to calculate tips for a meal, you might create a field, a button, and a label (using the development environment), and write a handler for the button like this:

handler calcButton.onselect() {
  float price;
  // get the meal's price
  price = fieldPrice.text;
  // do the math and set the label's text
  labelTip.text = price * 0.15;
}

Object-oriented API

Much of the API exposed by the OrbC runtime is in the form of objects. For example, all the user interface elements (e.g. buttons, forms) are objects with methods (such as domodal(), and load()) and properties (such as x, y, visible). To demonstrate a small portion of the API usage, the following method below writes a record to a database. A database object is first created and opened, a record is retrieved from it, and some data (an "entry") is written:

void RecordManager.writeRecord() {
  // write the current record to the database
  Database db;
  DBRecord rec;

  // open the database
  if (db.open("Data", false)) {
    if (db.getrec(recIndex, rec, false)) {
      rec.write(&entry, typeof(entry), 1);
      rec.close();
    }
    db.close();
  }
}

Copyright (c) 1997-2008 OrbWorks