[Home]History of Plua/PluaDoc

Amatubu_Wiki | RecentChanges | Preferences


Revision 19 . . October 9, 2006 15:15 by Amatubu
Revision 18 . . October 9, 2006 13:20 by Amatubu
Revision 15 . . (edit) May 28, 2006 12:49 by Amatubu
  

Difference (from prior major revision) (author diff)

Changed: 167c167
* pevent([n]): blocks until an event is generated. Events can be a hard button press, a pen event, a UI control selection or whether there is IO pending. The first returned value is always the event type: penDown, penUp, penMove, keyDown, ctlSelect, ctlRepeat, popSelect, lstSelect, menuSelect, ioPending, sampleStop (these constants are already pre-defined). For pen events, 2 more number are returned: the x,y cursor position. For key events, 1 more number is returned: the key code. For UI control events, 2 more number are returned: the control ID and the control state (1=selected, 0=not selected). For list events and popup events, 2 more number are returned: the list ID and the selected element. For menu event, the index of the menu item (starting with 1) is also returned. The IO pending event (nothing else is returned) is a efficient way for a program to wait for IO without polling. If the optional n parameter is passed, pevent() will wait at most n millisecons for an event. If no event happens, it will return the constant nilEvent.
* pevent([n]): イベントが発生するまで停止します。イベントはハードボタンを押したというイベント、ペン入力イベント、UI コントロールの選択や、IO 待ちがある場合に発生します。最初の戻り値は常にイベントのタイプです: penDown、penUp、penMove、keyDown、ctlSelect、ctlRepeat、popSelect、lstSelect、menuSelect、ioPending、sampleStop のいずれかです(これらの定数は定義済みです)。ペンイベントの場合、さらに 2 つの数値が返されます: カーソル位置の x,y です。キーイベントの場合、さらに 1 つの数値が返されます: キーコードです。UI コントロールイベントの場合、さらに 2 つの数値が返されます: コントロール ID とコントロールの状態(1=選択されている、0=選択されていない)です。リストイベントとポップアップイベントの場合、さらに 2 つの数値が返されます。リスト ID と選択されたエレメントです。メニューイベントの場合、メニューアイテムのインデックス(1 から始まる)も返されます。IO 待ちイベント(ほかには何も返されない)はプログラムが IO をポーリングなしに待つための効率的な方法です。オプションのパラメータ n が指定された場合、pevent() は最大で n ミリ秒の間イベントを待ちます。イベントが何も起こらなかった場合、定数 nilEvent を返します。

Changed: 190,195c190,195
* psleep(s): pauses the execution for s seconds (s can be a decimal number). Returns nothing.
* pcopy(s): copies the string s to the clipboard. Returns nothing.
* ppaste(): returns a string with the contents of the clipboard.
* pmem(): returns used memory and total memory, both in KB.
* loadlib(name): loads a C library built with libkit. Returns a number identifying the loaded library or nil in case of error.
* removelib(id): unloads a C library loaded with loadlib. Returns nothing.
* psleep(s): 実行を s 秒間(s は整数)停止します。何も返しません。
* pcopy(s): 文字列 s をクリップボードにコピーします。何も返しません。
* ppaste(): クリップボードの内容の文字列を返します。
* pmem(): 使用中のメモリと総メモリを KB 単位で返します。
* loadlib(name): libkit で作られた C ライブラリを読み込みます。読み込まれたライブラリを識別する数値を返すか、エラーが起こった場合は nil を返します。
* removelib(id): loadlib で読み込まれた C ライブラリを解放します。何も返しません。

Changed: 303c303
Although PalmOS does not have a true filesystem, Plua provides the Lua virtual machine the illusion that the underlying OS supports file I/O. The "stdout" descriptor is mapped to the display. The "stderr" descriptor is mapped to a dialog box that shows what was printed on stderr.
PalmOS は本当のファイルシステムを持っていませんが、Plua は Lua バーチャルマシンに基礎となる OS が I/O をサポートしているように見せかけます。"標準出力(stdout)" 識別子はディスプレイにマッピングされ、"標準エラー出力(stderr)" 識別子はダイアログボックスにマッピングされ、stderr に書き込まれたものを表示します。

Changed: 305c305
Regular files are implemented using the File Stream API of PalmOS, so Lua programs can open, create, read from and write to files normaly, without knowing about database types or database creators. The following example shows this:
標準的なファイルは PalmOS の File Stream API を用いて実装されています。このため、Lua プログラムは通常通りファイルを開き、作成し、読み書きすることができます。データベースタイプやクリエータを知ることなく。以下の例がそのことを示しています:

Changed: 311c311
The database MyOutput is open for writting (it is created if it does not exist), a string is written to it, and it is closed.
データベース MyOutput が書き込み用に開かれ(もし存在しなければ作成されます)、文字列が書き込まれ、閉じられます。

Changed: 313c313
There are also functions that allow a program to manipulate a PalmOS database directly, if desired. They were listed in the section "Extensions to the standard Lua distribution" above. The example below iterates through all MemoPad records and prints the first line of each record:
PalmOS のデータベースを直接操作するための関数も存在します。もしそうしたいならば。それらは上記の "標準の Lua ディストリビューションからの拡張機能" セクションにリストされています。以下の例はすべての MemoPad レコードについて、それぞれのレコードの 1 行目を表示します:

Changed: 323c323
The read() function belongs to the standard I/O Lua library. The I/O functions work with both stream files and regular databases. With regular databases, each record works like a sub-file, that is, they can be read from the begining to the end, when an EOF conditions is signaled. In order to continue to read the database, openrec() must be called to open the next record and so on.
read() 関数は Lua ライブラリの標準 I/O に属します。I/O 関数はストリームファイルにも標準のデータベースにも同じように働きます。標準のデータベースの場合、それぞれのレコードはサブファイルのように働き、すなわち、EOF 状態になったとき、最初から最後まで読み込まれたということです。データベースからの読み込みを続けるためには、次のレコードを開くために openrec() を呼び出さなければなりません。

Changed: 325c325
The available modes for opendb() are:
opendb() に有効なモードは以下の通りです:

Changed: 327,329c327,329
* "r": opens the database for reading only.
* "r+": opens the database for reading and writing. The database is created if it does not exist. In this case, the creator is inherited from Plua and the type is always 'data'.
* "w": opens the database for writing only. The database is created if it does not exist. In this case, the creator is inherited from Plua and the type is always 'data'.
* "r": データベースを読み込み用に開きます。
* "r+": データベースを読み込みと書き込み用に開きます。データベースが存在しない場合には作成されます。この場合、クリエータは Plua のものが引き継がれ、タイプは常に 'data' となります。
* "w": データベースは書き込み用に開きます。データベースが存在しない場合には作成されます。この場合、クリエータは Plua のものが引き継がれ、タイプは常に 'data' となります。

Changed: 331c331
The first two modes also accept the "b" suffix (like "rb" or "r+b"), which means binary mode. If a record is read in binary mode, the last character is ignored if it is ASCII 0 (nul). This is necessary because applications like MemoPad always write a nul as the last character of a record. In some cases this nul must be ignored, while in others (like binary data) it may be significant.
最初の 2 つのモードには "b" を追加することができます("rb" や "r+b" というように)。これはバイナリモードを意味します。レコードがバイナリモードで読み込まれるとき、最後の文字が ASCII 0(ヌル文字)の場合この最後の文字は無視されます。この機能は、MemoPad のようなアプリケーションはいつもレコードの最後にヌル文字を書き込むため、なくてはならないものです。あるケースではヌル文字を無視しなければなりませんが、ほかのケースでは(バイナリデータのような場合)重要です。

Changed: 337,345c337,345
* ENOENT (2): No such file or directory
* EIO (5): Input/output error
* EBADF (9): Bad file descriptor
* ENOMEM (12): Cannot allocate memory
* EACCES (13): Permission denied
* EEXIST (17): File exists
* EINVAL (22): Invalid argument
* EMFILE (24): Too many open files
* EFBIG (27): File too large
* ENOENT (2): そのようなファイルまたはディレクトリは存在しない
* EIO (5): 入出力エラー
* EBADF (9): 不正なファイル記述子
* ENOMEM (12): メモリ確保ができない
* EACCES (13): 権限がない
* EEXIST (17): ファイルが存在する
* EINVAL (22): 無効な引数
* EMFILE (24): ファイルが開かれ過ぎ
* EFBIG (27): ファイルが大きすぎる

Amatubu_Wiki | RecentChanges | Preferences
Search:

Copyright (c) 1996-2019 naoki iimura e-mail