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
  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 -1 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 signed 15 bit 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-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 result is returned as a signed 15 bit integers. The truth table for this operation is
Bit1result
01
10
R4RS Compliance LispMe extension
Examples
(bit-not 17) => -18
(bit-not -16384) => 16383

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 signed 15 bit 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-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.

Shift amounts are interpreted modulo 64, since 68000 family processors treat them this way.

R4RS Compliance LispMe extension
Examples
(bit-shift 6 4) => 96
(bit-shift 1 14) => -16384 (max. sensible shift amount)
(bit-shift 1 15) => 0 (all bits shifted out)
(bit-shift 16000 -8) => 62
(bit-shift -16000 -8) => -63
(bit-shift 6 68) => 96 (like first example)

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 signed 15 bit 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

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

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