id | CLSID or object title from the registry |
forceNew | Try to create a new object |
The constructor tries to connect the active object in a COM class. If there is no active object, it will try to create one with CoCreateInstance(). The constructor will throw an exception if the COM class does not implement the IDispatch interface. If you use a second parameter (of any value), a new COM object will always be created. |
Closes the COM object and frees unused ActiveX libraries. |
If a COM property ID is less than 255, it will appear as an automatic property of the JS object. Otherwise, use get() and set() to read and change property values. Recognized VARIANT types are BOOLEAN, INT4, DOUBLE, NULL, BSTR, IUnknown, and IDispatch. |
If a COM property ID is less than 255, it will appear as an automatic property of the JS object. Otherwise, use get() and set() to read and change property values. The property must accept VARIANT types of BOOLEAN, INT4, DOUBLE, NULL, or BSTR. |
invokes the COM toString(...) method. If that function doesn't exist, it returns the property with index=0.
idl file: [propget, id(0), helpstring("property toString")] HRESULT toString([out,retval] VARIANT *rv); implementation: STDMETHODIMP CFoo::get_whoami(VARIANT *rv) { rv->vt = VT_BSTR; rv->bstrVal = SysAllocString(L"[Foo object]"); return S_OK; } |
count | Number | Number of files included in the archive. |
The constructor needs a seekable stream (like a file or memory) or a filename. The stream used to open the archive will be kept open (even if it is deleted) until the archive is freed. |
Returns the compressed string contents. |
Returns the uncompressed string contents. |
Closes the archive and frees the stream. |
If the 2nd parameter is a stream, data are uncompressed to that stream. Otherwise, a new memory stream is returned containing the file data. |
Returns the index of the file, or -1 if it does not exist |
Returns true if the file is in the archive |
Returns the filename. |
Returns the uncompressed size of the file. |
count | Number | number of questions |
file_id | Number | FORM tag index (usually zero) |
name | String | the filename of the EZF file |
options | Record | form options |
name | Form filename, XML text, or a Stream. |
index | A HTML file may contain multiple |
Responses | Pipe-delimited list of codes and values |
Options | Pipe-delimited list of options |
Before | Insert before this question (-1 for end) |
fieldname | Field name |
Returns the question number (starting with 0) that matches a given fieldname. |
index | Question number (starting with 0) |
Retrieves a question type. Question types are:
Text Password Date Time Number Radio Weighted Check Single Multiple Combo Rank Hidden Section Page RichText Image PlainText ToolButton |
index | Question number (starting with 0) |
Returns true if the field can contain data, or false if it's a layout object. |
index | Question number |
Determines if the question starts a new page. This is the case if
|
start | Question index |
finish | Question index |
Moves a question from the start position to the finish position in the form. The other questions are rearranged, so you should be careful about using this while iterating over the questions. |
index | Question index |
Deletes a question. The questions after index are moved up, so you should be careful about using this while iterating over the questions. |
filename | optional new file name |
Saves changes. |
index | Question number (starting with 0) |
type | New value |
Changes a question type. See getType() for the list of types. |
colors | Number | Number of colors (in addition to the background) |
height | Number | Height |
size | Number | Number of bytes as a GIF file |
width | Number | Width |
height | Height |
width | Width |
Creates a new GIF image. The background color is white (color 0) and the transparent color is 127. There are 126 user-definable colors. |
X1 | start point |
Y1 | start point |
R | radius |
start | start angle (radians) |
stop | stop angle (radians) |
color | Color index |
Draws an arc. |
R | 0..255 |
G | 0..255 |
B | 0..255 |
Adds a new color and returns its index. |
X1 | start point |
Y1 | start point |
color | Color index |
Fills all connected background-colored pixels with the new color. |
X1 | x position |
Y1 | y position |
Returns the pixel value at a point |
X1 | start point |
Y1 | start point |
X2 | end point |
Y2 | end point |
color | Color index |
Draws a 1-pixel line. |
X | start point |
Y | start point |
color | Color index |
text | Text to display |
background | Background color index (default is 0) |
Prints text. At present, the only font is 9-pixel sans-serif. |
R | 0..255 |
G | 0..255 |
B | 0..255 |
Sets the background color value (color 0). |
X1 | x position |
Y1 | y position |
C | color |
Set a pixel value |
X1 | start point |
Y1 | start point |
R | radius |
start | start angle (radians) |
stop | stop angle (radians) |
color | Color index |
Draws a filled pie slice |
out | destination file or web connection |
Writes a GIF file |
value | Key value |
Appends a key to the next slot in the index |
value | Key value |
Returns the index of one entry matching the key value, or -1 if the key is not in the index. |
Rebuilds an index created by Table.index(). |
name | String | connection string |
type | mail system type: one of CCMAIL5, CCMAIL8, CCMAIL, BEYONDMAIL, VIM, NOTES, MAPI, MSMAIL, EXCHANGE, GROUPWISE, CMC, INTERNET, POP3, SMTP |
login | account name |
password | password |
server | server address or windows mail profile |
smtpserver | Internet mail server, if different from the POP3 server |
language | MIME language string, like USASCII or ISO-8859-1 |
return address | Return mail address (generally useful if sending mail) |
Connects to a mail server. In the case of internet mail (INTERNET, POP3, SMTP are equivalent), the password is unnessary. The return email address is login@server. |
Returns a message summary table. The table has a getMessage() function you can use to retrieve the message text. If the Mail system is closed, this table will be deactivated. |
recipient | comma-delimited list of recipient email addresses |
subject | subject line |
textNote | note |
htmlNote | HTML version of note (Internet mail only) |
Sends a mail message. |
recipient | comma-delimited list of recipient email addresses |
subject | subject line |
attachments | comma-delimited list of files |
textNote | note |
htmlNote | HTML version of note (Internet mail only) |
Sends a mail message with file attachments. |
cols | Number | Number of columns |
data | Array | Number of columns |
rows | Number | Number of rows |
Constructs a new matrix, where rows are separated by , and columns by spaces. new Matrix("1 0, 0 1") is the 2x2 identity. |
rows | Number of rows |
cols | Number of columns |
data | Initial data |
Constructs a new matrix, using data as its elements (in row-major order). You can pass a Numbers object if you plan to work with a lot of data. |
Fits the Nx2 data to a polynomial of order O. Returns an array C such that the x^p coefficient of the least-squares fit is C[p]. |
Returns a new NxN identity matrix |
Given a square matrix S and vector Y, returns X such that S · X = Y |
Same as get() |
Returns a copy of the matrix. |
Returns the entry at row,column. No bounds-checking. |
Same as set() |
Updates the entry at row,column. No bounds-checking. |
Returns A · B. |
Returns the transpose of the matrix. |
Resets the matrix to all zeros |
Fast and efficient ordered list of 64-bit floating point numbers. Numbers acts like Array, providing
for .. in and [] operators, but the get() and set() functions are much more efficient.
length | Integer | Number of elements in this list. |
Creates a new array, initialized to 0. |
Creates a new array, initialized by converting values to numbers. Space, comma, or tab are good delimiters, but other characters will work, too, with a slight performance penalty. |
Creates a new array, copying an existing Numbers object. |
Increments each list element by value |
Same as get() |
Immediately frees the memory used for this object |
This is a special function for doing fast vector operations with a RPN evaluator. Each parameter passed to this function may be a Numbers object (all of the same length!) or a String naming the mathematical operation. In the example
a = new Numbers(5) b = new Numbers("1 2 3 4 5") c = new Numbers("10 20 30 40 50") a.exec(b,c,'+') writeln(a)the result is 11,22,33,44,55 The calculator stack starts as (b, c, '+'), and the result is stored in a (the object that called exec()). Arguments are evaluated left-to-right, so a is always the result of each operation and the number on the bottom of the stack for the next operation You can also do a = new Numbers("1 2 3 4 5") b = new Numbers("10 20 30 40 50") a.exec(b,'+') writeln(a)with the same result -- in case of stack underflow, the object calling exec() is pushed to the bottom of the stack. This function may have as many arguments as you want, so long as all the lists are of the same length. The supported operators, and the number of arguments they take, are:
Special: unary negation and division (inversion) are allowed, as a shortcut |
Returns the number at the index location. Throws an error if index is out of bounds. |
Replaces each list element by its log (base e) |
Returns the index of the largest value in the list. Use start and length to operate on a subset of the list. |
Returns the index of the smallest value in the list. Use start and length to operate on a subset of the list. |
Raise each list element to the power p |
Same as set() |
Changes the length of the underlying list. If the length increases, new memory is allocated. If the length decreases, memory is not freed (but subsequent growth, up to the original length, will not use lead to a memory allocation). New entries are initialized to 0. |
Multiplies each list element by value |
Updates the number at the index location. Throws an error if index is out of bounds. |
Returns the sum of all the numbers in the list. Use start and length to operate on a subset of the list. |
Returns the sum of the square of all the numbers in the list. Use start and length to operate on a subset of the list. Why would you want to do this? To calculate the standard deviation quickly.
var n = new Numbers("1 495 52 2 34 5 6 1 12 35 6 2 34") writeln("Average: ",n.sum()/n.length) writeln("Average of the square: ", n.sum2()/n.length) |
Although the Numbers class acts like the JavaScript Array class by default, you may customize the formatting with any delimiter (default is a comma). Use start and length to operate on a subset of the list. |
className | String | "ODBC" |
error | String | The last error message. It is initially undefined, and only changes when a query() or exec() function fails. |
name | String | Driver name |
connection string | "DSN=source_name;UID=login;PWD=password;" |
Connects to an ODBC driver. You can also use var myDB = new ODBC("DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=dbname;USER=root;PASSWORD=password;OPTION=3;"); var myReader = myDB.query('select * from people'); or var myT = new Table('odbc://DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=dbname;USER=root;PASSWORD=password;OPTION=3;/people') The difference is that the query() function gives you a read-only table, while the Table() constructor lets you make changes with set() and setRow(). You might see a "Dialog failed" message from Microsoft. This only means that there's something wrong with your connection string. JSDB is a mediocre command-line SQL console. Use Raosoft's SQL.exe instead. |
Closes the connection to the database and all tables that were opened with the query() function. The table objects are invalidated (further function calls will fail), but they are not deleted. |
table | A table name |
Returns an array of all the column names for the specified table. If longFormat is true, the return value will look like ["id INTEGER","name VARCHAR(32)","value DECIMAL(12,5)"]. |
Commits the current transaction. |
text | Field text to send to the database |
Quotes and escapes text as appropriate for the database. Usage: db.exec("insert into friends (name) values (" + db.escape('Cynthia') + ")") |
command | "ALTER TABLE ..." |
Same as ODBC.execute(). |
command | "ALTER TABLE ..." |
This calls SQLExecDirect() on the database. Returns true if the operation was successful. You can read the error parameter to find out what went wrong otherwise. |
table | A table name |
Returns a list of all the key names for the specified table. |
query | "SELECT * FROM table WHERE ..." |
Executes an SQL command, and returns the result set mapped into a read-only Table object. The Table object provides a cache and indexed access to records, even if the ODBC driver does not. If you just want to read from a SQL table with a simple query, this is equivalent to new Table('odbc://userid:password@service/tablename?field1=xxx*&field2=yyy'). Both ways of accessing the tables do on-demand loading of data from the database server. |
Rolls back the current transaction, if the database is not in AUTOCOMMIT mode. |
value | New setting |
Sets the database AUTOCOMMIT flag, which usually defaults to true when the ODBC connection is opened. |
name | Table name |
Opens a Table object in the database. |
Returns an array of all the table names in the database. |
active | Boolean | Whether the program is still running. |
className | String | "Process" |
exitCode | Number | If done, the program's exit code. |
cmd | Command line, .exe file name, or document name |
args | Arguments |
The constructor tries to start a program. Only programs ending in .exe will be run. On Windows, if cmd is a document file or URL, Process queries the Windows shell to run the appropriate program to open the document. Note that file names must be fully qualified. |
Sends a quit message to the child process and frees associated handles. |
caseSensitive | Boolean | Are fields case sensitive? |
count | Number | Number of name-value pairs stored by the record |
length | Number | Number of name-value pairs stored by the record |
initial | Delimited string for initial values (a=b,c=d,e=f,...) |
delimiter | Delimiter character, default is a comma |
Creates a record with initial values. See read(). |
caseSensitive | true for a case-sensitive list |
Creates a record. Use Record(true) for name searches to be case-sensitive. |
caseSensitive | true for a case-sensitive list |
Creates a record. Use Record(true) for name searches to be case-sensitive. |
data | Any JavaScript object |
Creates a record, copying fields and values from an Object. The Record will be case-sensitive. |
data | Additional data |
Appends the name/value pairs from another record or object. If field names match, they are overwritten. |
Deletes all the name/value pairs from the record. |
name | Field name |
Returns the value of a field, or an empty string if the field does not exist. |
name | Field name |
Returns true if the field exists in the record. |
index | Index from 0 to length - 1 |
Name/value pairs are indexed sequentially. This function returns the name at a given position. |
data | Delimited string to read (a=b&c=d&e=f&...) |
delimiter | Delimiter character, default is & (think of HTTP GET) |
Reads a delimited string into the record. |
file | INI file name (in Windows directory by default) |
section | INI file section |
Reads a Windows INI file section.Returns the number of entries. |
name | Field name or index |
value | New value |
Sets a field value, or creates a name/value pair if it doesn't already exist. |
Generates a JS Object from the record data. |
Returns a '\n'-delimited list of the record. |
name | Field name |
Removes a name/value pair if it exists. |
index | Index from 0 to length - 1 |
Name/value pairs are indexed sequentially. This function returns the value at a given position. |
delimiter | Delimiter character, default is & (think of HTTP GET) |
Returns a delimited string of the record's name-value pairs. |
file | INI file name (in Windows directory by default) |
section | INI file section |
Writes a Windows INI file section. Returns the number of entries. |
database | File name |
Opens or creates a SQLite3 database file. Creates an in-memory database if the file name is omitted. |
Closes the database and frees associated memory. |
table | A table name |
Returns an array of all the column names for the specified table. If longFormat is true, the return value will look like ["id INTEGER","name VARCHAR(32)","value DECIMAL(12,5)"]. |
text | Field text to send to the database |
Quotes and escapes text as appropriate for the database. Usage: db.exec("insert into friends (name) values (" + db.escape('Cynthia') + ")") |
command | SQL statement |
callback | Callback function |
opaque | Parameters passed to the callback function |
Executes a SQL statement. If rows are returned, runs callback(record, opaque) for each row in the result set. The result record is reused. See Query Language Understood by SQLite. |
table | A table name |
Returns a list of all the key names for the specified table. |
Returns an array of all the table names in the database. |
anyoneWaiting | Boolean | is a client waiting for a response? |
hostName | String | |
port | Number |
port | Default port is 80. |
Accepts the next connection in the input queue and returns a Stream pointer to communicate with it. |
Closes the server and all connections. |
Describes the server configuration and port. |
name |
Filename, URL, Number of bytes for a memory stream. URLs are of the form:
http://www.jsdb.org/ file://c:/test.txt net://server.com:port com1://56000 (or com2, com3, ...) text://number_of_bytes temp://number_of_bytes exec://command line | ||||||||||||||||||||||||||||||||||||||||||||
mode |
For files mode, is the open mode (rwactb+). A + indicates an unbuffered stream and a b indicates binary mode.
The default mode is 'rt' (read a text file).
For http:// streams, mode chooses how to connect and what data to retrieve.
For net:// streams, mode chooses the socket parameters.
| ||||||||||||||||||||||||||||||||||||||||||||
header | For http:// streams, pass additional header lines to the server. | ||||||||||||||||||||||||||||||||||||||||||||
If name is a string, jsdb will first try to open a URL.
To retrieve a web page using GET and standard headers, use Stream('http://server.com/'). The status property will be initialized with the first line from the server response. To simply open a socket to the server and send your own headers, use a = new Stream('net://server.com:80/'); a.writeln('POST /file.cgi/ HTTP/1.1\r\n'). The port number defaults to 80 if it is omitted. A file:// URL is always opened in binary, read-only mode. If name does not appear to be a URL (no ://), jsdb will try to open a file instead. Forward slashes are converted to back slashes when opening files in Windows. If name is fifo://, an in-memory FIFO will be created. If name is omitted or is a number, an in-memory stream will be created, with the initial length given by name. If name starts with "exec://", the stream returns a pipe to a spawned process. Try this: p = new Stream("exec://jsdb.exe","d") p.writeln("writeln('hello world');") writeln(p.readln()) p.writeln("quit"); |
data | Stream to append |
length | Max number of bytes to read |
Appends bytes from data until its end. Remember to rewind data before using it in a call to append()! |
data | Stream to append |
length | Max number of bytes to read |
Like append(), but maps '\n' to \r\n'. This is used to prepare text for a windows edit control. |
Resets a memory stream. The length is set to zero, and the position returned to the beginning, but memory is not freed. |
Closes the file and frees associated memory. |
skip | Characters to skip |
Reads the stream one byte at a time. If a byte is not in the skip string, it returns
a string containing that byte. A null character always stops the scan. Example:
var lastchar = file.eatChars(' \t\r\n')
|
For file streams, flush the 64k buffer. To create an unbuffered file stream, open it with the "+" option. |
This function was removed in version 1.7.2.7. You can replace it with
Stream.prototype.format = function(source, values) { this.write(source.replace(/{(.*?)}/g, function (x, name) {return values.get(name)} )) } |
Reads one byte from the stream and advances the cursor. |
Moves the cursor backward offset bytes from the current position.. |
Moves the cursor forward offset bytes from the current position. |
Returns the next byte in the file or memory stream, without advancing the cursor. Since HTTP and COM streams aren't buffered, you should avoid using this function unless you know the source of the stream. |
Writes one byte to the stream and advances the cursor. |
Moves the cursor backward offset bytes from the current position.. |
count | number of bytes |
dest | Optional target for retrieved data |
Reads up to a fixed number of bytes from a file, and returns them as a string. If dest is provided, readFile() runs instead of read() |
Same as readUInt8() |
size | Maximum number of bytes |
dest | Where to store the data |
Reads the entire stream into a string in binary mode. size and dest may be in any order. If dest is provided, the return value is the number of bytes actually copied. Otherwise, the return value is a string. The stream is read in binary mode, so the string may contain embedded nulls. |
Reads a 32-bit floating point |
Reads a double from the stream |
network | Network byte order? |
Reads a binary, signed 32-bit integer in Intel byte format. (JavaScript uses 31 bit integers internally). Set network=true for Sun or Mac native byte order. |
network | Network byte order? |
Reads a binary, signed 16-bit integer in Intel byte format. |
network | Network byte order? |
Same as readInt(). |
Reads a binary, signed 8-bit integer. |
Same as readln. |
data | Receptable for returned data |
delimiter | Delimiter to use (default is probably "\n", but is not guaranteed) |
equals | Name/value separator (default is "=") |
Reads a delimited name-value list. The delimiter and equals sign must be single characters.
Note that "\r\n" in files is mapped to "\n" in memory, so the default input it expects is
name=value
name1=value1
name2=value2
Returns the number of pairs read.
|
Deprecated in 1.7.2.5. Reads data from a Record in binary format. Each parameter is terminated with a null byte, the last with two null bytes. |
data | Receptacle for parsed data |
Reads a name-value list in MIME format. This takes whitespace after the colon into account, and assumes that any non-blank line beginning with whitespace is a continuation line. Returns the number of pairs read. |
delimiter | May be "" for null-byte termination |
Reads the next string in a message queue, terminated by a delimiter character. If no message is available, returns null. If a message is in transmission, this function blocks until it is complete or the stream is closed. |
data | Tag fields |
allowed | Comma-delimited list of allowed fields, case-sensitive |
Used for parsing XML files. This function scans forward in a file until a markup tag is
found. If allowed is given, only tags (and end-tags) in the list will stop a scan. Otherwise,
any < sign stops the scan. The text skipped in this scan is stored in the stream's parameter
tagText.
When it reaches a tag, it reads the tag parameters, and stores them in data. The XML escape sequences < > & and " are automatically decoded in the parameters, but not in CDATA sections. If the tag has an end marker, (ex: <tag field=value />), the stream's parameter hasChildren is set to false. Otherwise, hasChildren is true. The tag name is returned. If the end of the file has been reached, the return value is an empty string. If the tag name is "![CDATA[", readTag() searches forward for "]]>", and appends the intervening text to tagText. For an example of how this is used, see the module "xml.js".
var params = new Record;
var name = stream.readTag(params,allowed);
|
Reads the entire stream, converting all linefeeds to \r\n. Returns a string of the result. |
network | Network byte order? |
Reads a binary, unsigned 16-bit integer in Intel byte format. |
Reads a binary, unsigned 8-bit integer. |
search | String that stops the search |
skipped | Skipped data is written to this stream |
Returns true if the search string was found. readUntil() does a case-insensitive text search. For a binary search, use
readUntilBytes(). If search is a unicode string, it will be converted
to UTF-8. Example:
var memory = new Stream
var file = new Stream('test.txt')
file.readUntil('</file>',memory)
writeln(memory)
|
search | Byte pattern that stops te search |
skipped | Skipped data is written to this stream |
The binary version of readUntil(), readUntilBytes() can search for patterns with embedded nulls. |
delimiter | End-of-line character (default '\n') |
Returns the next line in the file. At the end of the file, it returns an empty string "". |
size | Specifies the new buffer size |
Resizes a memory stream. If the stream decreases, data are truncated from the end. If the cursor is beyond the end of the stream, it is moved to the new end. If the stream is expanded, memory is allocated, but no new data are added. |
For file and memory streams, moves the cursor to the beginning of the stream.
Example:
temp = new Stream
temp.write('hello, world')
temp.rewind()
file = new Stream('test.txt','at')
file.append(temp)
|
Moves the cursor to a new offset from the beginning. |
length | New maximum file length |
Changes the length of a a file or memory stream. Memory streams can be truncated. File streams can be truncated or extended. |
For a file, COM, or HTTP stream, this returns the filename. For a memory stream, it returns the entire buffer. |
data... | Objects to write to the stream |
Example: stream.write('hello', '4', 5). If the parameters to this function are not strings, their toString() function will be called. Returns the number of bytes written. |
Same as writeUInt8 |
Converts value to a number and writes it to the stream as a 32-bit floating-point number. |
Writes a double to the stream. |
network | Network byte order? |
Writes a binary, signed 32-bit integer in Intel byte format. |
network | Network byte order? |
Writes a binary, signed 16-bit integer in Intel byte format. |
network | Network byte order? |
Same as writeInt(). |
Writes a binary, signed 8-bit integer. |
Same as writeln. |
data | Data to write |
delimiter | Delimiter to use (default is probably "/", but is not guaranteed) |
equals | Name/value separator (default is "=") |
Writes a delimited name-value list. You can specify any string to use for the record and field delimiters. Default output is name=value/name1=value1/name2=value2/... Returns the number of pairs written. |
Writes data from a Record in binary format. The C++ equivalent is
for (int i=0; i< data.count; i++)
{
fwrite(data[i].name,1,strlen(data[i].name) + 1, file);
fwrite(data[i].value,1,strlen(data[i].value) + 1, file);
}
fwrite("",1,1,file);
|
data | Data to write |
Writes a name-value list in MIME format. This is equivalent to writeList(data,': ','\n'). A blank line ends the list. Returns the number of pairs written. |
network | Network byte order? |
Writes a binary, unsigned 16-bit integer in Intel byte format. |
Writes a binary, unsigned 8-bit integer. |
Like write(), but appends a newline (\n for memory, \r\n for files). The file I/O system ensures that, for text mode files, \n in memory is faithfully mapped to \r\n on disk. You can use pos and seek() to move the cursor in text files, but do not rely on counting the bytes in read() and write() operations. |
name | data source name |
Opens a table. The data source name may be omitted to create an in-memory spreadsheet, or like one of these:
file://drive:/directory/filename.asc file://drive:/directory/filename.dbf file://user:password@DSN/filename.dsn odbc://login:password@data_source/table The file:// prefix is optional, except for the DSN hack to open an ODBC connections. |
name | Name of a new table to create |
fields | "fieldname [type] length, ..." |
(new in 1.7)
Creates a new xBase table. name is a file name (.dbf). fields is a list of
column definitions, for example name C 33, address C 33, age N 3.
Field names can be up to 10 characters. The field type and length are optional, they defaul to C and 255. The maximum field length is 65535. For xBase compatibility, the total record length should less than 65535. type can be Character, Number, Date, or Time (only the first letter is needed). |
data | initial values |
Adds a new row to the table, populating it with values from data, and returning the number of the new row.
SQL databases:
|
name | column name |
Adds a new column, which must have a unique name, and returns the new column's number. |
source | source table |
callback | callback function |
opaque | opaque parameter for callback |
Copies data from another table.
The callback function is of the form function cb(record, opaque, ...), where record is the row number about to be transferred, and opaque (and the ...) are extra parameters passed to append(). |
column | field name |
This finds the column number corresponding to a field name. If the field name does not exist in the database, the return value is zero. |
row | row number (starting with 1) |
column | column number or name |
Returns text |
data | row number |
Deletes a row from the table. |
column | column number |
Removes a column from a spreadsheet table. |
query |
values to search for, for example:
query = {name: 'Alice'} // faster: new Record('name=Alice'); row = table.find(query) |
start | row number from which to start searching (defaults to the first row) |
direction | +1 to search forward, or -1 to search backwards |
The result of the last search is stored in the table's lastFind property. Deleted rows are skipped during the search. |
query | query from find() |
Continues the last search. |
row | row number (starting with 1) |
column | column number or name |
Same as data() |
row | row number (starting with 1); |
For mail message tables, returns the message text. |
row | row number |
data | data values |
Returns a record containing the values from a row in the table. If the "data" parameter is used, then it is filled with the values and the function returns true or false. |
row | Row number (starting with 1) |
For debugging ODBC tables, returns the WHERE statement used to identify a particular row. |
column | Column name |
This function returns an index to the database. If you call index()
with a single column name or number, the returned object will have find(key) function,
where key can be either a field value or a Record/Object containing the appropriate field value.
If you call index() with a list of field names, the index will be built from strings where data values are separated by newlines. Therefore, you can call index().find('value1\nvalue2\nvalue3') or index().find(new Record('field1=value1,field2=value2,field3=value3'). The index().find() function returns the number of a matching row, or -1 if none are found. Since it takes time to build the index, you can do something like this: data = {fieldname: 'Field Value'} var index = table.index('field') writeln('adding record ',table.addRow(data)) index.add(data) writeln('found record ',index.find(data)); |
file | file name |
delimiter | Defaults to the delimiter used to read the file or tab |
titles | Defaults to true |
Save databsae changes. If the database has no file name, the function
fails. For ODBC databases, this forces a COMMIT statement. For DBF databases,
nothing happens.
For ASCII databases, you can save to a file name or a stream. In this case, you select a delimiter (or null for the default) and choose whether to include the header row. |
row | row number (starting with 1) |
column | column number or name |
value | new value |
Set text data at a position in the table. You can delete a row with table.set(row,0,'Delete') With DBF and SQL tables, you can un-delete a row with table.set(row,0,' ') DBF tables do not remove deleted rows. SQL tables remove deleted rows when they refresh, which is not necessarily immediate. Spreadsheets delete rows immediately. |
row | row number (starting with 1) |
column | column number or name |
value | new value |
Set number data at a position in the table. The number will usually be converted to text to store it in the database. |
row | row number |
data | data values |
Sets data values into the table. Returns true on success. |
column | column number |
title | new title |
Changes a column's title. This only works for spreadsheet (ASCII and in-memory) tables. |
column | column number |
Returns the title of a column. Column numbers start at 1. You can find the number of columns in a table from the colCount property. |
Returns the file name |
column | Column name |
For one argument, this returns the data type corresponding to the row. For several arguments, this returns an array of data types. The possible types are C, N, D, T for Character, Number, Date, and Time. |
column | column number |
Returns the width, in characters, of data that may be stored in this column. Spreadsheet tables do not have a width limit. |
The JavaScript 1.6 language includes a built-in XML parser complying with the E4X standard.
This XML class pre-dates E4X, and can be used to replace the built-in XML object.
Standard usage: XML.read(stream,allowed_tags)
cdata | String | |
children | Array | |
name | String | |
params | Record |
dtd | comma-delimited list of tag names |
ignored | comma-delimited list of tags to ignore (defaults to BR,P,B,I,C,TT,U,IMG,A) |
start | an existing XML object to receive the new XML tags |
This is a static function. Usage: XML.read(stream, 'html,head,body,p') |
type | Child class |
parameter | Field name |
value | Field value |
parameter2 | Field name |
value2 | Field value |
Returns an array of all the child objects whose name is equivalent (case-sensitive) to type |
type | Child class. If omitted, searches all children |
parameter | Field name. If omitted, skips the field comparison |
value | Field value |
(Deprecated) Returns an array of all the child objects whose name is equivalent (case-sensitive) to type and which has a matching field value. Example: fn.find('parameter','optional','1') returns the list of optional parameters for the XML file that generates this document. Use XML.find() to return a list of all the children |
name | Parameter name |
Returns the field value corresponding to name. If the field value is missing, this returns an empty string. To test for the existence of a field, use params.has('name'). |
type | Child class |
(Deprecated) Returns an array of all the child objects whose name is equivalent (case-sensitive) to type |
type | Child class |
test | Test function |
opaque | Parameter passed to the test function |
Returns an array of all the child objects for which the test() function returns true. Example: >var x = XML.read(' |
field | Field to sort by |
descending | Reverse order? (Default false) |
Sorts the children array, according to the value in a given field. |
output | Appends the XML object to a stream. |
Appends the XML object to a memory stream, then returns a string. |
jsArguments | Array | Also available as system.arguments. A list of command line arguments (as strings) |
Deprecated in 1.7. Use system.copy() instead. Copies files. Fails if the destination file exists. |
seed | Usually -1 |
Calculates the 32-bit CRC of a text string, using the Adler32 polynomial. The initial seed may be specified (usually -1). The parameters may be passed in any order. |
Converts a Windows-1252 (ANSI) string to a JS string (UCS-2) |
Removes base-64 (MIME) encoding and returns an decoded string. Does not convert to Unicode -- call decodeUTF8(decodeB64(...)) if you want a JS string. |
Applies base-64 (MIME) decoding and sends the result to out. Returns the size of the decoded data. |
Removes & encoding and returns an decoded string. It decodes < > " & and XX; sequences. |
Decodes a URL-encoded string. |
Converts UTF-8 string to a JS string (UCS-2) |
Applies base-64 (MIME) encoding and returns an encoded string. |
Applies base-64 (MIME) encoding and sends the result to out. Returns the size of the encoded data. |
For XML and HTML printing, applies & encoding and returns an encoded string. It encodes < > " & and Unicode character values over 127. |
Applies URL (%) encoding and returns an encoded string. Alphanumeric and punctuation characters used in URLs are not translated. |
Converts a JS string (UCS-2) to UTF-8 |
Deprecated in 1.7. Use system.exists() instead. Returns true if the file exists and is available for reading. |
Deprecated in 1.6. Use system.buildDate() instead. Returns a string containing the build date of the JavaScript interpreter. |
address | Debugger address |
Deprecated in 1.6. Use system.debug() instead. Connects to a remote debugger. jsDebug('127.0.0.1:1002') |
Deprecated in 1.6. Use system.gc() instead. Runs garbage collection |
Deprecated in 1.6. Use system.isSafe() instead. Tells whether the interpreter is in safe mode. |
options | 'strict' or 'werror' (treat warnings as errors) |
Deprecated in 1.6. Use system.options() instead. Toggles the interpreter options, and returns a comma-delimited string of the currently set options. By default, strict is active at startup. |
Deprecated in 1.6. Use system.restart() instead. Sets the "shouldStop" flag to true, and instructs the interpreter to repeat execution. This is only used in the XYKE web server. |
code | password |
Deprecated in 1.6. Use system.safeMode() instead. Sets a flag in the interpreter to indicate that file access should be forbidden while running an untrusted piece of code. The first call to jsSafeMode() returns a pseudo-random number, and locks file access. The second call, to unlock file access, must be of the form jsSafeMode(number), where the first parameter is the number returned by the call to jsSafeMode() that locked file access. In safe mode, email is blocked, and only memory streams and http:// streams may be created. File and serial port streams that were opened outside of safe mode may still be accessed. |
command | shell command line |
dir | working directory |
Deprecated in 1.6. Use system.execute() instead. Calls ShellExec() on Windows, or system() on UNIX. |
Deprecated in 1.6. Use system.shouldStop() instead. Returns true if the script should finish. |
new version | New interpreter version number |
Deprecated in 1.6. Use system.version() instead.
Returns a string containing the JavaScript interpreter version number (or the previous version, if the version is changing).
The default version is presently 1.7. The version codes are defined as JSVERSION_1_0 = 100, JSVERSION_1_1 = 110, JSVERSION_1_2 = 120, JSVERSION_1_3 = 130, JSVERSION_1_4 = 140, JSVERSION_ECMA_3 = 148, JSVERSION_1_5 = 150, JSVERSION_1_6 = 160, JSVERSION_1_7 = 170, JSVERSION_DEFAULT = 0, JSVERSION_UNKNOWN = -1 |
filespec | defaults to "*.*" |
Deprecated in 1.7. Use system.files() instead. Returns an array of file names. Directories and are excluded. System files, hidden files, and names beginning with . are excluded. |
filespec | defaults to "*.*" |
Deprecated in 1.7. Use system.folders() instead. Returns an array of directory names. Files are excluded. System folders, hidden folders, and names beginning with . are excluded. |
Runs a JavaScript file. JSDB looks first for files with the following precedence:
This order is chosen so that you may override the standard JSDB libraries, but carries certain security risks. For instance, someone might write a malicious "xml.js" in the current directory, expecing that library to be loaded by another script later. Therefore, you should be careful about calling the system.cwd() function. As with run(), load() will fail if JSDB is in safe mode. Unlike run(), load() will only execute a given source file only once. Files will be reloaded if they have been modified. |
Deprecated in 1.6. Use system.resource() instead. Returns a readable stream containing the resource data. The resource file is either in the ZIP file attached to or in the same directory as the interpreter program. |
Deprecated in 1.7. Use system.move() instead. Moves a file. Fails if the destination file exists. |
file | URL |
Deprecated in 1.7. Use system.browse() instead. |
Prints the parameters to stdout, calling toString() if necessary. Does not convert to UTF-8. Unicode values in strings will be truncated to 8 bytes. |
Like print() and write(), but writes CR/LF at the end. |
Deprecated in 1.6. Use system.quit() or system.exit() instead. Sets the "shouldStop" flag to true. Execution does not stop immediately. |
end | Line end marker, defaults to \n |
Reads a line from stdin. Console mode only. |
section | "hkey_local_machine\SOFTWARE\..." |
name | Key name |
Deprecated in 1.7. Use system.getKey() instead. Returns a string containing the registry data. |
section | "hkey_local_machine\SOFTWARE\..." |
name | Key name |
value | Key value |
Deprecated in 1.7. Use system.setKey() instead. Sets a registry entry. Returns true if successful. |
Deletes a file or directory. Returns true if successful. |
Runs a JavaScript file. Run uses the same file-finding rules as load(). |
Runs JavaScript code stored in a stream. The functions run() and load() are equivalent |
time | milliseconds |
Deprecated in 1.6. Use system.sleep() instead. Suspends the process and yields control to other programs. |
Parses a URL of the form service://user:password@host/file?query, and returns an array of strings: [service, user, password, host, file, query] |
Returns a string with initial and final whitespace characters removed. |
Returns true if console input is available. |
code | JS code to test |
Deprecated in 1.7. Use system.compile() instead. Returns whatever error messages if there's a problem compiling the code. |
Returns an object describing the specified file. { attributes: String, size: Number, date: Date, creation: Date } On Windows, attributes can include "archive, compressed, directory, hidden, offline, readonly, system, temporary". On Unix, attributes can include "directory, symlink, regular, chardev, blockdev, fifo, socket". |
file | File name | ||||
Returns an object describing the file system attributes, {attributes: String, size: Number, creation: Date, date: Date}.
Attributes may be
|
file | URL |
Opens the default web browser on the console, and points it to the specified URL. |
code | JS code to test |
Returns error messages if there's a problem compiling the code. |
Copies files. Fails if the destination file exists. |
address | Debugger address |
Connects to a remote debugger. system.debug('127.0.0.1:1002') |
command | shell command line |
parameters | parameters |
dir | working directory |
Calls ShellExec() on Windows, or system() on UNIX. |
Returns true if the file exists and is available for reading. |
Sets the "shouldStop" flag to true. Execution does not stop immediately. |
filespec | defaults to "*.*" |
Returns an array of file names. Directories and are excluded. System files, hidden files, and names beginning with . are excluded. |
filespec | defaults to "*.*" |
Returns an array of directory names. Files are excluded. System folders, hidden folders, and names beginning with . are excluded. |
Runs garbage collection. |
section | "hkey_local_machine\SOFTWARE\..." |
name | Key name |
Returns a string containing the registry data. (Windows only) |
name | variable name |
Returns an environment variable. |
Returns information about the interpreter version. Look for "JSDB 1.1 ...". |
Tells whether the interpreter is in safe mode. |
Creates a directory (recursively). Always returns true. |
replace | Set to true to overwrite existing files |
Moves a file. |
options | 'strict', 'werror' (treat warnings as errors), 'atline', 'xml' (enable E4X in subsequent load() and run() calls) |
Toggles the interpreter options, and returns a comma-delimited string of the currently set options. By default, strict is active at startup. |
Prints the parameters to stdout, calling toString() if necessary. |
Like print() and write(), but writes CR/LF at the end. |
Sets the "shouldStop" flag to true. Execution does not stop immediately. |
end | Line end marker, defaults to \n |
Reads a line from stdin. Console mode only. |
Returns a readable stream containing the resource data. The resource file is either in the ZIP file attached to or in the same directory as the interpreter program. |
Sets the "shouldStop" flag to true, and instructs the interpreter to repeat execution. |
code | password |
Sets a flag in the interpreter to indicate that file access should be forbidden while running an untrusted piece of code. The first call to jsSafeMode() returns a pseudo-random number, and locks file access. The second call, to unlock file access, must be of the form system.safeMode(number), where the first parameter is the number returned by the call to system.safeMode() that locked file access. In safe mode, email is blocked, and only memory streams and http:// streams may be created. File and serial port streams that were opened outside of safe mode may still be accessed. |
section | "hkey_local_machine\SOFTWARE\..." |
name | Key name |
value | Key value |
Sets a registry entry. Returns true if successful. (Windows only) |
Note use system.cwd='foobar' instead Sets the current working directory (if directory is not empty) and returns the previous working directory. On Windows, the directory name is unicode. Otherwise, it is treated as ASCII, without UTF-8 encoding.. |
Returns true if the script should finish. |
time | milliseconds |
Suspends the process and yields control to other programs. |
Returns a string with initial and final whitespace characters removed. |
objects | objects (like streams) which can be signalled |
timeout | milliseconds |
Suspends execution for timeout (default forever) milliseconds until one or more objects is signalled. Signals include: internet streams with incoming data, closed internet streams, servers with pending connection requests. If you want to test an object which is not an internet stream or a server object, that object can either have a canRead property which evaluates to true when the object is signalled, or it can have a toStream() function that returns an internet stream or server. The toStream() call is limited to 8 or so levels of recursion. |