Back to index A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Other

Alphabetic catalog of Language elements B

battery-info

battery-info lists information about the current battery status.

Category Native procedure
Format (battery-info)
Parameters none
Description battery-info returns detailed information about the Palm's battery status as a list of seven items:
  1. current voltage [V]
  2. warning voltage [V]
  3. critical voltage [V]
  4. ticks until low battery warning
  5. battery kind, see SysBatteryKind in System/SystemMgr.h
    0sysBatteryKindAlkalineAlkaline
    1sysBatteryKindNiCadNickel/Cadmium
    2sysBatteryKindLiIonLithium ion
    3sysBatteryKindRechAlkRechargable alkaline
    4sysBatteryKindNiMHNickel metal hydride
    5sysBatteryKindLiIon1400Lithium ion, 1400 mAh
  6. are we plugged in?
  7. percentage of battery remaining
R4RS Compliance LispMe extension
Examples
(battery-info) => (4.02 3.64 2 65535 5 #f 100)

begin

begin sequentially evaluates expressions.

Category Special form
Format (begin expr1 expr2 ...)
Parameters
expri ... expressions, which are evaluated sequentially
Description begin evaluates each expri in sequence from left to right. The value of the last expri is returned.

A second use of begin is to group mutually recursive define expressions entered into the command line.

R4RS Compliance Full
Examples
(begin 'a "foo" 42) => 42

bit-and

bit-and bitwise ands its arguments.

Category Primitive procedure
Format (bit-and ni ...)
Parameters
nian integer
Description bit-and ands the bit pattern of any number of integer numbers. The arguments are interpreted as 2's complement signed binary integers. The truth table for this operation is
Bit1Bit2result
000
010
100
111
R4RS Compliance LispMe extension
Examples
(bit-and) => -1 (all bits set)
(bit-and 52 41) => 32
(bit-and -1000000 345678) => 1088

bit-not

bit-not bitwise complements its argument.

Category Primitive procedure
Format (bit-not n)
Parameters
nan integer
Description bit-not inverts every bit in its argument. The argument is interpreted a signed binary integer. The truth table for this operation is
Bit1result
01
10
R4RS Compliance LispMe extension
Examples
(bit-not 17) => -18
(bit-not -16384) => 16383
(bit-not -1000000) => 9999999

bit-or

bit-or bitwise ors (inclusive) its arguments.

Category Primitive procedure
Format (bit-or ni ...)
Parameters
nian integer
Description bit-or inclusively ors the bit pattern of any number of integer numbers. The arguments are interpreted as 2'complement signed binary integers. The truth table for this operation is
Bit1Bit2result
000
011
101
111
R4RS Compliance LispMe extension
Examples
(bit-or) => 0 (no bits set)
(bit-or 52 41) => 61
(bit-or -1000000 345678) => -655410

bit-shift

bit-shift bitwise shifts its argument.

Category Primitive procedure
Format (bit-shift n k)
Parameters
nan integer
kan integer
Description bit-shift shifts n by k bits to the left (if k is positive) or to the right (if k is negative). All shifts are signed, i.e. they preserve the most significant bit in the standard two's-complement representation of integers.

R4RS Compliance LispMe extension
Examples
(bit-shift 6 4) => 96
(bit-shift 1 14) => 16384 (no more limited to SMALLINTS)
(bit-shift 1 64) => 18446744073709551616
(bit-shift 17 -10000) => -1

bit-xor

bit-xor bitwise ors (exclusive) its arguments.

Category Primitive procedure
Format (bit-xor ni ...)
Parameters
nian integer
Description bit-xor exclusively ors the bit pattern of any number of integer numbers. The arguments are interpreted as 2's complement signed binary integers. The truth table for this operation is
Bit1Bit2result
000
011
101
110
R4RS Compliance LispMe extension
Examples
(bit-xor) => 0 (no bits set)
(bit-xor 52 41) => 29
(bit-xor -1000000 345678) => -656498

bitmap

bitmap draws a bitmap.

Category Native procedure
Format (bitmap bmap)
Parameters
bmapa string (see below)
Description bitmap draws a bitmap at the current point stored in *gstate* extending to the right and the bottom. The current point is not changed. The return value is #n to avoid trashing the graphics.

See here for details on the graphic state.

The string describing the bitmap uses the standard Pilot bitmap format adn supports colored and multiple bitmaps (OS 3.5), It's exactly the format stored in a bitmap resource (ResType Tbmp). This format corresponds to this C structure definition (from the 3.5 header Core/System/Bitmap.h)

typedef struct BitmapFlagsType {
  UInt16 compressed:1;      // Data format:  0=raw; 1=compressed
  UInt16 hasColorTable:1;   // if true, color table stored before bits[]
  UInt16 hasTransparency:1; // true if transparency is used
  UInt16 indirect:1;        // true if bits are stored indirectly
  UInt16 forScreen:1;       // system use only
  UInt16 reserved:11;
} BitmapFlagsType;

typedef struct BitmapType {
  Int16           width;
  Int16           height;
  UInt16          rowBytes;
  BitmapFlagsType flags;
  UInt8           pixelSize;        // bits/pixel
  UInt8           version;          // version of bitmap. This is vers 2
  UInt16          nextDepthOffset;  // # of DWords to next BitmapType
                                    //  from beginnning of this one
  UInt8           transparentIndex; // v2 only, if flags.hasTransparency is true,
                                    // index number of transparent color
  UInt8           compressionType;  // v2 only, if flags.compressed is true, this is
                                    // the type, see BitmapCompressionType
  UInt16          reserved;         // for future use, must be zero!
  // [colorTableType] pixels | pixels*
  // If hasColorTable != 0, we have:
  //   ColorTableType followed by pixels. 
  // If hasColorTable == 0:
  //   this is the start of the pixels
  // if indirect != 0 bits are stored indirectly.
  //   the address of bits is stored here
  //   In some cases the ColorTableType will
  //   have 0 entries and be 2 bytes long.
} BitmapType;
Caution: The Pilot API is very sensitive to the right initialization of these fields, especially that rowBytes must be even. Though LispMe checks some of these conditions, an invalid bitmap can cause a Fatal exception, so you should stick to bitmaps read from resources and be careful when assembling bitmaps on the fly.

You can retrieve the width and height of a bitmap with

(define (width bitmap)
  (+ (* 256 (char->integer (string-ref bitmap 0)))
       (char->integer (string-ref bitmap 1))))

(define (height bitmap)
  (+ (* 256 (char->integer (string-ref bitmap 2)))
       (char->integer (string-ref bitmap 3))))
As most bitmaps are smaller than 256 pixels, you can ignore the high-order byte:
(define (width bitmap) (char->integer (string-ref bitmap 1)))

(define (height bitmap) (char->integer (string-ref bitmap 3)))
R4RS Compliance LispMe extension
Examples
(bitmap (read-resource "Tbmp" 11000)) => #n and draws the famous easter egg taxi

boolean?

boolean? recognizes #t and #f.

Category Primitive procedure
Format (boolean? obj)
Parameters
objany object
Description boolean? returns #t for the boolean values #t and #f and returns #f for any other object. Remember that in LispMe () and #f are distinct objects.
R4RS Compliance Full
Examples
(boolean? '(a b c)) => #f
(boolean? '()) => #f
(boolean? #f) => #t
(boolean? #t) => #t

buf-get-cstr

buf-get-cstr reads a C string from a buffer.

Category Native procedure
Format (buf-get-cstr buf offset)
Parameters
bufa string
offseta string index
Description buf-get-cstr starts reading bytes from the string buf starting at offset offset until a NUL byte is encountered. All characters read (without the NUL terminator) are returned as a string.
R4RS Compliance LispMe extension
Examples
(buf-get-cstr ".Hello#00foo." 1) => "Hello"

buf-get-date

buf-get-date reads a PalmOS Date from a buffer.

Category Native procedure
Format (buf-get-date buf offset)
Parameters
bufa string
offseta string index
Description buf-get-date reads 2 bytes from the string buf starting at offset offset and interprets them as a PalmOS date which is returned as a LispMe date (foreign type).
R4RS Compliance LispMe extension
Examples
(buf-get-date ".#bf#0b." 1) => [date 11. Aug 1999]
(buf-get-date "#12#34" 0) => [date 20. Jan 1913]

buf-get-f32

buf-get-f32 reads a 32 bit IEEE real from a buffer.

Category Native procedure
Format (buf-get-f32 buf offset)
Parameters
bufa string
offseta string index
Description buf-get-f32 reads 4 bytes from the string buf starting at offset offset and interprets them as a 32 bit IEEE-754 single precision floating point real. Since all floating point calculation in LispMe is done in double precision, the result is extended accordingly.
R4RS Compliance LispMe extension
Examples
(buf-get-f32 ".#12#34#56#78." 1) => 5.69045661390352e-28

buf-get-f64

buf-get-f64 reads a 64 bit IEEE real from a buffer.

Category Native procedure
Format (buf-get-f64 buf offset)
Parameters
bufa string
offseta string index
Description buf-get-f64 reads 8 bytes from the string buf starting at offset offset and interprets them as a 64 bit IEEE-754 double precision floating point real which is returned.
R4RS Compliance LispMe extension
Examples
(buf-get-f64 ".#12#34#56#78#9a#bc#de#f0." 1) => 5.6263492749012e-221

buf-get-s16

buf-get-s16 reads a 16 bit integer from a buffer.

Category Native procedure
Format (buf-get-s16 buf offset)
Parameters
bufa string
offseta string index
Description buf-get-s16 reads 2 bytes from the string buf starting at offset offset and interprets them as a signed 16 bit integer (big endian) which is returned.
R4RS Compliance LispMe extension
Examples
(buf-get-s16 ".#12#34." 1) => 4660
(buf-get-s16 "#ff#ff" 0) => -1

buf-get-s32

buf-get-s32 reads a 32 bit integer from a buffer.

Category Native procedure
Format (buf-get-s32 buf offset)
Parameters
bufa string
offseta string index
Description buf-get-s32 reads 4 bytes from the string buf starting at offset offset and interprets them as a signed 32 bit integer (big endian) which is returned.
R4RS Compliance LispMe extension
Examples
(buf-get-s32 ".#12#34#56#78." 1) => 305419896
(buf-get-s32 "#ff#ff#ff#ff" 0) => -1

buf-get-s8

buf-get-s8 reads a 8 bit integer from a buffer.

Category Native procedure
Format (buf-get-s8 buf offset)
Parameters
bufa string
offseta string index
Description buf-get-s8 reads 1 byte from the string buf from offset offset and interprets it as a signed 8 bit integer which is returned.
R4RS Compliance LispMe extension
Examples
(buf-get-s8 ".#12." 1) => 18
(buf-get-s8 "#ff" 0) => -1

buf-get-time

buf-get-time reads a PalmOS Time from a buffer.

Category Native procedure
Format (buf-get-time buf offset)
Parameters
bufa string
offseta string index
Description buf-get-time reads 2 bytes from the string buf starting at offset offset and interprets them as a PalmOS time which is returned as a LispMe time (foreign type).
R4RS Compliance LispMe extension
Examples
(buf-get-time ".#0b#37." 1) => [time 11:55]
(buf-get-time "#12#34" 0) => [time 18:52]

buf-get-ts

buf-get-ts reads a PalmOS Timestamp from a buffer.

Category Native procedure
Format (buf-get-ts buf offset)
Parameters
bufa string
offseta string index
Description buf-get-ts reads 4 bytes from the string buf starting at offset offset and interprets them as a PalmOS timestamp which is returned as a LispMe timestamp (foreign type).
R4RS Compliance LispMe extension
Examples
(buf-get-ts ".#12#34#56#78." 1) => [ts 1913-09-04-22-51-36]
(buf-get-ts "#b3#d7#1f#94 0) => [ts 1999-08-11-12-39-48] (who remembers?)

buf-get-u16

buf-get-u16 reads a 16 bit unsigned integer from a buffer.

Category Native procedure
Format (buf-get-u16 buf offset)
Parameters
bufa string
offseta string index
Description buf-get-u16 reads 2 bytes from the string buf starting at offset offset and interprets them as an unsigned 16 bit integer (big endian) which is returned.
R4RS Compliance LispMe extension
Examples
(buf-get-u16 ".#12#34." 1) => 4660
(buf-get-u16 "#ff#ff" 0) => 65535

buf-get-u32

buf-get-u32 reads a 32 bit unsigned integer from a buffer.

Category Native procedure
Format (buf-get-u32 buf offset)
Parameters
bufa string
offseta string index
Description buf-get-u32 reads 4 bytes from the string buf starting at offset offset and interprets them as an unsigned 32 bit integer (big endian) which is returned.
R4RS Compliance LispMe extension
Examples
(buf-get-u32 ".#12#34#56#78." 1) => 305419896
(buf-get-u32 "#ff#ff#ff#ff" 0) => 4294967295

buf-get-u8

buf-get-u8 reads a 8 bit unsigned integer from a buffer.

Category Native procedure
Format (buf-get-u8 buf offset)
Parameters
bufa string
offseta string index
Description buf-get-u8 reads 1 byte from the string buf from offset offset and interprets it as an unsigned 8 bit integer which is returned.
R4RS Compliance LispMe extension
Examples
(buf-get-u8 ".#12." 1) => 18
(buf-get-u8 "#ff" 0) => 255

buf-set-cstr!

buf-set-cstr! writes a C string to a buffer.

Category Native procedure
Format (buf-set-cstr! buf offset str)
Parameters
bufa string
offseta string index
stra string
Description buf-set-cstr! writes the string str to the string buf starting at offset offset. A terminating NUL byte is written, too. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-cstr! "........" 1 "hello")) => ".hello#00."

buf-set-date!

buf-set-date! writes a PalmOS Date to a buffer.

Category Native procedure
Format (buf-set-date! buf offset date)
Parameters
bufa string
offseta string index
datea LispMe Date
Description buf-set-date! converts date to a PalmOS date and writes its 2 bytes to the string buf starting at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-date! "...." 1 (make-date 2002 1 30)) => ".Ä>."

buf-set-f32!

buf-set-f32! writes a 32 bit IEEE real to a buffer.

Category Native procedure
Format (buf-set-f32! buf offset real)
Parameters
bufa string
offseta string index
reala real
Description buf-set-f32! converts real to a 32 bit IEEE-754 floating point value and writes its 4 bytes to the string buf starting at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-f32! "......" 1 3.14159265) => ".@|#0fÛ."

buf-set-f64!

buf-set-f64! writes a 64 bit IEEE real to a buffer.

Category Native procedure
Format (buf-set-f64! buf offset real)
Parameters
bufa string
offseta string index
reala real
Description buf-set-f64! converts real to a 64 bit IEEE-754 floating point value and writes its 8 bytes to the string buf starting at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-f64! ".........." 1 3.14159265) => ".@#09!ûSÈÔñ."

buf-set-s16!

buf-set-s16! writes a 16 bit integer to a buffer.

Category Native procedure
Format (buf-set-s16! buf offset int16)
Parameters
bufa string
offseta string index
int16an integer from -32768 to 32767
Description buf-set-s16! converts int16 to a signed 16 bit binary integer and writes its 2 bytes to the string buf starting at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-s16! "...." 1 12345) => ".09."
(buf-set-s16! ".." 0 -1) => "ÿÿ"

buf-set-s32!

buf-set-s32! writes a 32 bit integer to a buffer.

Category Native procedure
Format (buf-set-s32! buf offset int32)
Parameters
bufa string
offseta string index
int32an integer from -2147483848 to 2147483647
Description buf-set-s32! converts int32 to a signed 32 bit binary integer and writes its 4 bytes to the string buf starting at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-s32! "......" 1 123456789) => ".#07[Í#15."
(buf-set-s32! "...." 0 -1) => "ÿÿÿÿ"

buf-set-s8!

buf-set-s8! writes a 8 bit integer to a buffer.

Category Native procedure
Format (buf-set-s8! buf offset int8)
Parameters
bufa string
offseta string index
int16an integer from -128 to 127
Description buf-set-s8! converts int8 to a signed 8 bit binary integer and writes the byte to the string buf at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-s8! "..." 1 123) => ".{."
(buf-set-s8! "." 0 -1) => "ÿ"

buf-set-time!

buf-set-time! writes a PalmOS Time to a buffer.

Category Native procedure
Format (buf-set-time! buf offset time)
Parameters
bufa string
offseta string index
timea LispMe Time
Description buf-set-time! converts time to a PalmOS time and writes its 2 bytes to the string buf starting at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-time! "...." 1 (make-time 21 15)) => ".#15#0f."

buf-set-ts!

buf-set-ts! writes a PalmOS Timestamp to a buffer.

Category Native procedure
Format (buf-set-ts! buf offset ts)
Parameters
bufa string
offseta string index
timea LispMe Timestamp
Description buf-set-ts! converts ts to a PalmOS timestamp and writes its 4 bytes to the string buf starting at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-ts! "......" 1 (make-ts #x12345678)) => ".#124Vx."

buf-set-u16!

buf-set-u16! writes a 16 bit unsigned integer to a buffer.

Category Native procedure
Format (buf-set-u16! buf offset uint16)
Parameters
bufa string
offseta string index
uint16an integer from 0 to 65535
Description buf-set-u16! converts uint16 to an unsigned 16 bit binary integer and writes its 2 bytes to the string buf starting at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-u16! "...." 1 65000) => ".ýè."

buf-set-u32!

buf-set-u32! writes a 32 bit unsigned integer to a buffer.

Category Native procedure
Format (buf-set-u32! buf offset uint32)
Parameters
bufa string
offseta string index
uint32an integer from 0 to 4294967295
Description buf-set-u32! converts uint32 to an unsigned 32 bit binary integer and writes its 4 bytes to the string buf starting at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-u32! "......" 1 4000000000) => ".îk(#00."

buf-set-u8!

buf-set-u8! writes a 8 bit unsigned integer to a buffer.

Category Native procedure
Format (buf-set-u8! buf offset uint8)
Parameters
bufa string
offseta string index
int16an integer from 0 to 255
Description buf-set-u8! converts uint8 to an unsigned 8 bit binary integer and writes the byte to the string buf at offset offset. The return value is the modified buffer.
R4RS Compliance LispMe extension
Examples
(buf-set-u8! "..." 1 234) => ".ê."

Back to index A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Other