Built-in Functions

Basic I/O

Event System

String

Math

Note: Functions that require MathLib will return integer 0 if the library is not present.

Graphics

Color Tables

Sound

Time/Date

Database I/O

All the database functions work on databases with any creator id/type, but use of resource databases may cause unexpected results. When creating a new database, the database will have creator id 'PktC' and type 'user'. An attempt to overwrite a database with a given name but different creator/type will fail. Only one database can be open at a time.

Memo Pad I/O

Serial I/O

int data[3], sbuff[8];
...
serrecva(sbuff, 8);
unpack(data, sbuff, "2<24", 8);

System

Memory Management

A few notes that will help understand the following section: In a normal computer, memory is divided into bytes and words. PocketC divides its memory into elements called "values". Each value stores a basic PocketC type (int, char, float, string, pointer). Also, each element of memory knows its own type (thus the need for the settype() function).

Networking

PocketC's networking support is based on BSD-style sockets. This documentation assumes you understand the functionality and is not intended to teach you to use BSD-style sockets. Currently only TCP sockets are supported. Almost all of the networking functions returns 0 on success and an error code on failure. To interpret the error code, you can call the neterror() function provided in neterror.h (in PocketC's UtilCode directory) which will convert the error code to a string.

All the functions that take and return addresses use a string representation. An address string is a dotted IP address with optional port, such as: "129.22.104.22:80" An empty string is interpreted as the local address. Thus, when calling sockbind(), only a port needs to be specified: ":1234". All socket methods (and the DNS methods) have a timeout associated with them. This timeout value is globally set using netsettimeout().

VFS

The Palm OS support for Virtual File Systems (VFS) allows an application to read and write files to removable storage, such as a compact flash card or memory stick. Almost all of the VFS functions returns 0 on success and an error code on failure. To interpret the error code, you can call the vfserror() function provided in vfserror.h (in PocketC's UtilCode directory) which will convert the error code to a string. This file also contains #defines for many useful VFS constants. Some methods do not work as documented on the emulator (attributes and dates will be incorrect).

To access a file, you must first retrieve the volume on which it resides using enumvols(). This function will enumerate all volumes on the device - if the device does not support VFS, no volumes will be returned. Once you have retrieved the volume id, you can use it to create and open files and directories. To get a list of all the files in a directory, first open the directory with volopendir(), then enumerate through the files and directories using direnum(). The get the files in the root directory, call direnm(dirid, "/"). Unlike traditional operating systems, the Palm OS VFS support does not support a concept of "current directory". Instead, all paths are fully specified for a given volume.