functions.html
来自「palm的pocketc」· HTML 代码 · 共 1,088 行 · 第 1/5 页
HTML
1,088 行
</li>
<li><b>2-bit Color Table:</b>
<table>
<tbody>
<tr>
<th>0</th>
<td width="24" bgColor="#ffffff"> </td>
<td width="24" bgColor="#c0c0c0"> </td>
<td width="24" bgColor="#808080"> </td>
<td width="24" bgColor="#000"> </td>
</tr>
</tbody>
</table>
</li>
<li><b>1-bit Color Table:</b>
<table>
<tbody>
<tr>
<th>0</th>
<td width="24" bgColor="#ffffff"> </td>
<td width="24" bgColor="#000"> </td>
</tr>
</tbody>
</table>
</li>
</ul>
<h3>Sound</h3>
<ul>
<li><i>beep(int type)</i> - generates a system sound, where type is between 1 and 7.
Available sounds are info[1], warning[2], error[3], startup[4], alarm[5], confirmation[6],
and click[7]. Note: not all sounds are unique in current versions of PalmOS. </li>
<li><i>tone(int freq, int dur)</i> - generates a tone of frequency freq (in Hz), and
duration dur (in milliseconds). </li>
<li><i>tonea(int freq, int dur, int vol)</i> - asynchronously generates a tone
of frequency freq (in Hz), duration dur (in milliseconds), at volume vol.
Calling this function with a 0 for any parameter will silence any currently
playing sound. This function does nothing on OS < 3.0. </li>
<li><i>getvol(int type)</i> - gets the current system volume setting for the
given sound type. Available types are system[0], game[1], alarm[2]. This
function returns maximum volume on OS < 3.0.</li>
</ul>
<h3>Time/Date</h3>
<ul>
<li><i>ticks()</i> - the number of clock ticks since last reset. On all
current devices there are 100 ticks per second. You can call <i>getsysval</i>
to determine this value. </li>
<li><i>seconds()</i> - the number of seconds since Jan 1, 1904 minus 2^31</li>
<li><i>time(int mode)</i> - returns the current time in the given <i>mode</i>. [mode 0] integer value (hour*100+minute) [mode 1] string value
(as determined by system preferences) [mode 2] integer value (hour*10000+minute*100+sec).</li>
<li><i>timex(int secs, int mode)</i> - same as time(), but uses the time
specified by <i>secs</i> which is the number of seconds since Jan 1, 1904
minus 2^31.</li>
<li><i>date(int mode)</i> - returns the current date in the given <i>mode</i>. [mode 0] integer value (year*10000+month*100+day) [mode 1] short
string value [mode 2] long string value (as determined by system preferences).</li>
<li><i>datex(int secs, int mode)</i> - same as date(), but uses the time
specified by <i>secs</i> which is the number of seconds since Jan 1, 1904
minus 2^31.</li>
<li><i>selecttime(int secs, string title)</i> - displays the time selection
dialog with the given <i>title</i> and initial time specified by <i>secs</i>
which is the number of seconds since Jan 1, 1904 minus 2^31. Returns the
selected time, or 0 if cancelled.</li>
<li><i>selectdate(int secs, int selectBy, string title)</i> - displays the
date selection dialog with the given <i>title</i> and initial date specified
by <i>secs</i> which is the number of seconds since Jan 1, 1904 minus 2^31.
Returns the selected date, or 0 if cancelled. <i>selectBy</i> may be day[0],
week[1], month[2].</li>
</ul>
<h3>Database I/O</h3>
<p>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.
<ul>
<li><i>dbopen(string name)</i> - opens the database named <em>name</em>, returns 0 on
failure. The current record is set to 0.</li>
<li><i>dbcreate(string name)</i> - creates and opens a database named <em>name</em>, returns
0 on failure. If another database of the same name and creator ID/type 'PktC' / 'user' exists, it
will first be erased. The current record is set to 0.</li>
<li><i>dbcreatex(string name, string creator, string type)</i> - creates and and opens a database named <em>name<i>
</i></em>with creator ID <i>creator</i> and type <i>type</i>, returns
0 on failure. If another database of the same name and creator ID/type exists, it
will first be erased. The current record is set to 0.</li>
<li><i>dbrename(string name)</i> - rename the currently open database. <i>name</i>
must be 31 characters or less.</li>
<li><i><em>dbrec(int recnum) - </em></i>sets the current record to <em>rec</em> and the
current position to 0. If the record is greater than the current number of records, future
reads will fail. However, the next write will create a new record at the end of the
database and set the current record to it.</li>
<li><em>dbnrecs()</em> - returns the number of records in the current database.</li>
<li><em>dbsize()</em> - returns the size of the current record in bytes.</li>
<li><i>dbwrite(data)</i> - write the value <em>data</em> at the <strong>end</strong> of the
current record. <em>data</em> can be of any type, use casting to ensure that data is the
correct type. Use caution when writing in the middle of a database with null-terminated
strings, as they are of unknown length.</li>
<li><i>dbread(char type)</i> - read a value from the current position in the database. A
value must be read as the same type that it was written. Available types are 'c' char, 'i'
int, 'f' float, 's' string.</li>
<li><em>dbreadx(pointer ptr, string format)</em> - Using the current database, read data of
the the given <em>format</em> into the data pointed to by <em>ptr</em>. <em>format</em> is
the same as <em>dbwritex()</em>. Returns the number of values read.</li>
<li><em>dbreadxc(pointer ptr, string format, int count)</em> - Same as <i>dbreadx</i>,
but repeats the specified <i>format</i> <i>count</i> times. Returns the
number of values written.</li>
<li><em>dbwritex(pointer ptr, string format)</em> - Using the current database, write data
pointed to by <em>ptr</em> and described by <em>format</em> at the current position in the
current record. <em>format</em> contains a list of data types, one per value following <em>ptr</em>.
Data types are 'c' - a single byte, 'i2' - a 2-byte word, 'i4' - 4-byte double word, 'f' -
a 4-byte float, 'sz' - a null-terminated string, 's#' - a string of length #.
To specify more than 1 of a type, prefix it with a count number - '12i2'
means 12 2-byte words. When a count number would be is next to a size
number, separate them with a '.' - '12i2.8f' means 12 2-byte words followed
by 8 floats. Returns the
number of values written.</li>
<li><em>dbwritexc(pointer ptr, string format, int count)</em> - Same as <i>dbwritex</i>,
but repeats the specified <i>format</i> <i>count</i> times. Returns the
number of values written.</li>
<li><i>dbpos()</i> - get the current location in the database. -1 indicates the end has been
reached. </li>
<li><i>dbseek(int loc)</i> - set the current location. If this value is greater than the
length of the database, the next call to dbread() will set the position to -1. </li>
<li><i>dbbackup(int flag)</i> - flag [0] clear backup bit, [1] set backup bit, [2] query
backup bit. </li>
<li><i>dbclose()</i> - close the current database. </li>
<li><i>dbdelete()</i> - delete and close the current database.</li>
<li><em>dberase()</em> - erases the content of the current record (but does not remove the
record).</li>
<li><em>dbdelrec(int recnum)</em> - deletes the specified record from the current database.
This removes the contents of the record and sets its 'delete' bit, which will cause the
record to be removed on the next HotSync. Returns 0 on error.</li>
<li><em>dbarcrec(int recnum)</em> - archives the specified record from the current database.
This maintains the contents of the record and sets its 'delete' bit, which will cause the
record to be removed and archived on the next HotSync. Returns 0 on error.</li>
<li><em>dbremrec(int recnum)</em> - removes the specified record from the current database.
This removes all traces of the record. Returns 0 on error.</li>
<li><i>dbmoverec(int from, int to)</i> - remove the record at index <i>from</i>
and insert it at index <i>to</i>. </li>
<li><em>dbenum(int first, string type, string creator)</em> - enumerates the databases
installed on the device, by type and/or creator. Returns 0 if no more databases are
available. The type and creator are each 4 character strings, or the empty string for a
wildcard. To get the first database, you must set first=1. To get the subsequent matching
databases you must set first=0. </li>
<li><i>dbgetcat()</i> - returns the category ID for the current record. </li>
<li><i>dbsetcat(int catID)</i> - sets the category ID for the current record
(must be a number between 0 and 15). </li>
<li><i>dbmovecat(int from, int to, int dirty)</i> - Move all records from
category<i> from</i> to category <i>to</i>. If <i>dirty</i> is true, the
records which have move will be marked as dirty. </li>
<li><i>dbcatname(int catID)</i> - returns the name of the category given its
category ID. </li>
<li><i>dbsetcatname(int catID, string name)</i> - sets the name of the category given its
category ID. </li>
<li><i>dbinfo(string name, pointer pstrType, pointer pstrCreator)</i> -
retrieve the type and creator ID of the database named <i>name</i>. <i>pstrType</i>
and <i>pstrCreator</i> must be pointers to strings. Returns 1 on success, 0
on failure. </li>
<li><i>dbtotalsize(string name)</i> - retrieves the total size of all records
in the database named <i>name</i>. Returns 0 on failure. </li>
<li><i>dbgetappinfo()</i> - converts the current database's app info block to
a record, and sets the current record to this temporary record. If
successful, returns the temporary record id. On failure, sets the current
record to -1. Before closing the database, you must remove this temporary
record or convert it back to an app info block. </li>
<li><i>dbsetappinfo()</i> - removes the current record and sets the app info
block to its contents. Sets the current record to -1. Returns 1 on success. </li>
</ul>
<h3>Memo Pad I/O</h3>
<ul>
<li><i>mmnew()</i> - create a new, empty memo, returns 0 on failure. </li>
<li><i>mmfind(string name)</i> - opens the memo with name as its first line, returns 0 on
failure. </li>
<li><i>mmfindx(string name)</i> - opens the memo with name as its first line,
and returns the record id of the memo, or -1 for failure. </li>
<li><i>mmopen(int id)</i> - opens the memo with the given id, returns 0 on failure. This
function is not recommended, but is included for completeness. </li>
<li><i>mmputs(string)</i> - appends the given string to the end of the memo. </li>
<li><i>mmgetl()</i> - retrieves a string from the current position in the memo. Does not
include the newline.</li>
<li><i>mmeof()</i> - returns 1 if at the end of the memo, 0 otherwise. </li>
<li><i>mmrewind()</i> - rewind the current memo to the beginning. </li>
<li><i>mmclose()</i> - close the current memo. </li>
<li><i>mmdelete()</i> - delete and close the current memo.</li>
<li><em>mmcount()</em> - returns the number of records in the memo pad database.</li>
</ul>
<h3>Serial I/O</h3>
<ul>
<li><i>seropen(int baud, string flags, int timeout)</i> - open the serial port. Tested
baud rates are 300-57600, higher rates are theoretically possible. flags is a 4-char
string in the form "8N1C" [bits/char (6,7,8) parity (N,E,O) stop bits (1,2) flow
control (X-software, C-CTS, R-RTS, H-CTS/RTS, N-None)]. timeout is the number of clock ticks (1/100 sec) to
wait between bytes for data. Returns 0 for success. seropenx is preferable
if your device has OS 3.3 or higher. </li>
<li><i>seropenx(int port, int baud)</i> - open the serial/IR port using the
new serial manager. Returns 0 for success. Requires OS 3.3 or higher.
Available port numbers are 0x8000 - cradle port, 0x8001 - raw IR port (works
on devices not based on OMAP processor),
0x6972636D - IrComm (works on most newer devices), 0x7266636D - RfComm (bluetooth).</li>
<li><i>sersettings(string flags, int timeout)</i> - set the flags and timeout
as described in seropen. Use this function only when opening the serial port
with seropenx. </li>
<li><i>serclose()</i> - close serial port. </li>
<li><i>sersend(char byte)</i> - send a byte, return 0 on success. </li>
<li><i>serrecv()</i> - receive a byte, returns an integer 0-255 on success, > 255 on
failure. </li>
<li><i>serdata()</i> - return the number of bytes waiting in the receive
buffer.</li>
<li><i>serwait(int nBytes, int timeout)</i> - wait until <i>nBytes</i> bytes
are available in the receive buffer. <i>timeout </i>is the number of ticks
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?