Database I/O functions
| Plua 1
| Plua 2
| Description
|
| listdb("creator", "type")
| os.listdb(creator, type [, suffix])
| Returns a table with all databases matching the specified type and creator. Type and creator are either a 4 character string or an empty string to accept anything.
|
| opendb(name, mode)
| io.open(name, mode)
| Opens a PalmOS database. Mode can be "r" for read-only access, "r+" for read/write access, or "w" for write-only access. If mode is not read-only, the database is created if it does not exist. This function returns a handle to the open file and the number of records in the database. The handle is used as the first parameter in the other database I/O funtions. Returns nil if an error ocurred.
|
| closefile(file)
| f:close()
| Closes a database. Returns true if success or nil if an error ocurred.
|
| openrec(f, i)
| f:openrec(i)
| Opens the record with index i from an already open database f. Returns the size of the record or nil if an error occurred.
|
| createrec(f, size)
| f:createrec(size)
| Creates a new record with given size in (already open) database f. The record is added at the end of the database. The created record is NOT automatically opened. Returns the index of the new record or nil if an error ocurred.
|
| deleterec(f, i)
| f:deleterec(i)
| Deletes the record with index i from (already open) database f. The record can not be open when it is deleted. Returns true if success or nil if an error occurred.
|
| closerec(f)
| f:closerec(f)
| Closes the current open record of (already open) database f. Returns true if success or nil if an error occurred.
|
| resizerec(f, i, size)
| f:resizerec(i, size)
| Resizes the record with index i from (already open) database f to the specified size. If the record beeing resized is the currently open record, it is closed, resized and then reopened. Returns true if success or nil if an error occurred.
|
| getdbcat(f, n)
| f:getdbcat(n)
| Returns the name of category n (where 0 <= n <= 15) from already open database f.
|
| setdbcat(f, n, "cat")
| f:setdbcat(n, "cat")
| Sets the name of category n (where 0 <= n <= 15) to "cat" on already open database f. Returns the category name just set.
|
| deleterec(i)
| f:removerec(i)
| Removes the record with index i from (already open) database f. The record can not be open when it is removed. Returns true if success or nil if an error occurred.
|
| getreccat(f, i)
| f:getreccat(i)
| Returns the category number of record index i from already open database f.
|
| setreccat(f, i, n)
| f:setreccat(i, n)
| Sets the category number to n for record index i on already open database f. Returns the category number just set.
|
| ----
| f:getrecid(i)
| Returns the unique ID of record index i from already open database f.
|
Resource functions
| Plua 1
| Plua 2
| Description
|
| popenres("type", id [, file])
| resource.open("type", id [, file])
| Opens the resource with specified type (4 character string) and id. The resource is searched in all open databases or, if the optional file parameter is passed, only in the database named "file". Returns a number identifying the resource.
|
| pcloseres(r)
| resource.close(r)
| Closes the resource identified by number r. The number r is returned by the resource.open() function. Returns nothing.
|
| pgetres(r [, start [, end]])
| resource.get(r [, start [, end]])
| Returns a string with the contents of the resource identified by number r. You can optionally specify just a substring of the resource, with the start and end parameters. The number r is returned by the resource.open() function. Returns a string with the resource.
|
| pgetsize(r)
| resource.size(r)
| Returns the size of the resource identified by number r. If the resource is a bitmap, two additional numbers are returned: the width and the height of the bitmap. The number r is returned by the resource.open() function.
|
| pdrawbmp(r [, mode])
| resource.draw(r [, mode])
| Draws the bitmap resource identified by the number r in the current cursor position. The cursor is advanced to the right of the bitmap. The optional mode parameter affects how pixels are transfered to screen (0=paint, 1=erase, 2=mask, 3=invert, 4=overlay, 5=paint inverse). The number r is returned by the resource.open() function. If the resource is not a bitmap, this function has no efect. Returns nothing.
|
Screen functions
| Plua 1
| Plua 2
| Description
|
| pmode()
| screen.mode()
| Returns 4 numbers: screen width, screen height, screen depth and 1 or 0 indicating if the screen supports color. In interactive mode the screen height is half of the full-screen mode.
|
| pclear([c])
| screen.clear([c])
| Erases the screen with the background color or with the optional c color, and moves the cursor to 0,0. Returns nothing.
|
| pcolor(fg [,bg])
| screen.color(fg [,bg])
| Sets the foreground color (fg) and optionally the background color (bg). Returns nothing.
|
| prgb(r, g, b)
| screen.rgb(r, g, b)
| Returns the color equivalent to the (Red,Green,Blue) components.
|
| ppos()
| screen.pos()
| Returns 2 numbers with the current x,y cursor position.
|
| pmoveto(x, y)
| screen.moveto(x [,y])
| Moves the screen cursor to the x,y position. If y is omited the current y position is used.
|
| pline(x1, y1, x2, y2 [,c])
| screen.line(x1, y1, x2, y2 [,c])
| Draws a line from x1,y1 to x2,y2 using the fg color or the optional c color.
|
| plineto(x, y [,c])
| screen.lineto(x, y [,c])
| Draws a line from current position to x,y using the fg color or the optional c color.
|
| pset(x, y [,c])
| screen.set(x, y [,c])
| Draws a pixel at position x,y using the fg color or the optional c color.
|
| pget(x, y)
| screen.get(x, y)
| Return a number with the color index of pixel at position x,y.
|
| prect(x, y, dx, dy [,c])
| screen.rect(x, y, dx, dy [,c])
| Draws a rectangle at x,y, extending dx,dy pixels, using the fg color or the optional c color.
|
| pbox(x, y, dx, dy [,c])
| screen.box(x, y, dx, dy [,c])
| Draws a filled rectangle at x,y, extending dx,dy pixels, using the fg color or the optional c color.
|
| pcircle(x, y, rx, ry [,c])
| screen.circle(x, y, rx, ry [,c])
| Draws an ellipse centered at x,y, with rx,ry as x,y radius, using the fg color or the optional c color. Use rx=ry for a circle.
|
| pdisc(x, y, rx, ry [,c])
| screen.disc(x, y, rx, ry [,c])
| Draws a filled ellipse centered at x,y, with rx,ry as x,y radius, using the fg color or the optional c color. Use rx=ry for a filled circle.
|
| pfill(x, y, [,c])
| screen.fill(x, y, [,c])
| Starts a flood fill in the pixel located at x,y with current color or the optional c color. The filling stops at pixels with a different color than the initial pixel. Returns nothing.
|
| pfont(f)
| screen.font(f)
| Sets the text font to number f. Returns two numbers with the "average" width of a character and the height of a character, both in pixels. Note that PalmOS fonts are not fixed-width fonts, so if the returned width is used in calculations, you get just an approximation.
|
| ptextwidth(text)
| screen.textsize(text)
| Returns the width of the text string in pixels.
|
| pclip(x, y, dx, dy)
| screen.clip(x, y, dx, dy)
| Sets the clipping region to the rectangle at x,y, extending dx,dy pixels. If no parameter is passed the clipping region is reset. Returns nothing.
|
| pheading(g)
| screen.heading(r)
| Sets the turtle heading to r radians. 0 points to the right, math.pi/2 points up, and so on. Returns nothing.
|
| pturn(g)
| screen.turn(r)
| Turns the turtle r radians. r can be positive or negative and it is added to the current heading. Returns nothing.
|
| pwalk(d)
| screen.walk(d)
| Draws a line from the current cursor position, with extent d pixels and following the current heading. The cursor is positioned at the end of the line. Returns nothing.
|
| ----
| screen.jump(d)
| Moves the cursor d pixels from the current cursor position, following the current heading. Returns nothing.
|