database.majorErrorCode()
database.beginTransaction() statusCode = cursor.updateRow("rentals") if (statusCode == 0) { database.commitTransaction() if (statusCode == 5 || statusCode == 7) { write("The operation failed to complete.<BR>" write("Contact your system administrator with the following:<P>" write("The value of statusCode is " + statusCode + "<BR>") write("The value of majorErrorCode is " + database.majorErrorCode() + "<BR>") write("The value of majorErrorMessage is " + database.majorErrorMessage() + "<BR>") write("The value of minorErrorCode is " + database.minorErrorCode() + "<BR>") write("The value of minorErrorMessage is " + database.minorErrorMessage() + "<BR>") } database.rollbackTransaction() else { errorRoutine() }
database.majorErrorMessage()
1. Math.propertyName 2. Math.methodName(parameters)
Math.PI
. Constants are defined with the full precision of real numbers in JavaScript.
Similarly, you reference Math functions as methods. For example, the sine function is Math.sin(
argument)
, where argument is the argument.
It is often convenient to use the with statement when a section of code uses several Math constants and methods, so you don't have to type "Math" repeatedly. For example,
with (Math) { a = PI * r*r y = r*sin(theta) x = r*cos(theta) }
Math.max(number1, number2)
Examples
//Displays the value 20
document.write("The maximum value is " + Math.max(10,20))
//Displays the value -10
document.write("<P>The maximum value is " + Math.max(-10,-20))
See also
min method
method
Property. Provides the HTTP method associated with the request.
Syntax
request.method
Property of
request
Description
The value of the method property is the same as the value of the method property of the client-side form object; that is, method reflects the METHOD attribute of the <FORM> tag. For HTTP 1.0, the method property evaluates to either "GET" or "POST". Use the method property to determine the proper response to a request.
method is a read-only property.
Examples
The following example executes the postResponse() function if the method property evaluates to "post". If method evaluates to anything else, the getResponse() function executes.
<SERVER>
if (request.method=="post")
postResponse()
else
getResponse()
</SERVER>
See also
agent, ip, and protocol properties
min
Method. Returns the lesser of two numbers.
Syntax
Math.min(number1, number2)
Parameters
number1 and number2 are any numeric arguments or the properties of existing objects.
Method of
Math
Examples
//Displays the value 10
document.write("The minimum value is " + Math.min(10,20))
//Displays the value -20
document.write("<P>The minimum value is " + Math.min(-10,-20))
See also
max method
minorErrorCode
Method. Returns the secondary error code returned by the database vendor library.
Syntax
database.minorErrorCode()
Method of
database
Description
When the database methods execute, insertRow, updateRow, deleteRow, beginTransaction, commitTransaction, and rollbackTransaction fail they return a database status code to indicate the reason for failure. When that status code is 5 (server error) or 7 (vendor library error), the minorErrorCode method returns additional information about the failure.
The minorErrorCode method returns the secondary error code returned by the database vendor library.
See Interpreting Database Status Codes for a description of the individual status codes and Database Error Methods for a description of the platform-specific values returned by minorErrorCode.
Examples
See the example for the majorErrorCode method.
See also
majorErrorCode, majorErrorMessage, and minorErrorMessage methods
minorErrorMessage
Method. Returns the secondary message returned by the database vendor library.
Syntax
database.minorErrorMessage()
Method of
database
Description
When the database methods execute, insertRow, updateRow, deleteRow, beginTransaction, commitTransaction, and rollbackTransaction fail they return a database status code to indicate the reason for failure. When that status code is 5 (server error) or 7 (vendor library error), the minorErrorMessage method returns additional information about the failure.
The minorErrorMessage method returns the secondary message returned by the database vendor library.
See Interpreting Database Status Codes for a description of the individual status codes and Database Error Methods for a description of the platform-specific values returned by minorErrorMessage.
Examples
See the example for the majorErrorCode method.
See also
majorErrorCode, majorErrorMessage, and minorErrorCode methods
next
Method. Navigates to the next row in a cursor object.
Syntax
cursorName.next()
Parameters
cursorName is the name of a cursor object.
Method of
cursor
Description
The next method moves the pointer to the next row in a cursor object. The next method returns false if the current row is the last row in the cursor; otherwise, it returns true. See the cursor object for more information about the pointer.
Use the next method to iterate through the records in a cursor. When the last row in the answer set is the current row, the next method returns false.
Examples
Example 1. This example uses the next method to navigate to the last row in a cursor. The variable x is initialized to true. When the pointer is in the last row of the cursor, the next method returns false and terminates the while loop.
customerSet = database.cursor("select * from customer", true)
x=true
while (x) {
x = customerSet.next() }
Example 2. In the following example, the rentalSet cursor contains columns named videoId, rentalDate, and dueDate. The next method is called in a while loop that iterates over every row in the cursor. When the pointer is on the last row in the cursor, the next method returns false and terminates the while loop.
This example displays the three columns in the cursor in an HTML table.
<SERVER>
// Create a cursor object
rentalSet = database.cursor("SELECT videoId, rentalDate, returnDate
FROM rentals")
</SERVER>
// Create an HTML table
<TABLE BORDER>
<TR>
<TH>Video ID</TH>
<TD>Rental Date</TD>
<TD>Due Date</TD>
</TR>
<SERVER>
// Iterate through each row in the cursor
while (rentalSet.next()) {
</SERVER>
// Display the cursor values in the HTML table
<TR>
<TH><SERVER>write(rentalSet.videoId)</SERVER></TH>
<TD><SERVER>write(rentalSet.rentalDate)</SERVER></TD>
<TD><SERVER>write(rentalSet.returnDate)</SERVER></TD>
</TR>
// Terminate the while loop
<SERVER>
}
</SERVER>
// End the table
</TABLE>
See also
cursor method; cursor object
open
Method. Opens a file on the server.
Syntax
fileObjectName.open("mode")
Parameters
fileObjectName is a string specifying the name of a File object.
mode is a string specifying whether to open the file to read, write, or append, according to the list below.
Method of
File
Description
Use the open method to open a physical file before you read from it or write to it. If the file is already open, the method fails and the original file remains open. You must create a File object before you call the open method.
The mode parameter specifies whether to open the file to read, write, or append data. Following is a description of the mode parameter:
Examples
Example 1. The following example opens the file info.txt
so an application can write information to it. If info.txt
does not already exist, the open method creates it; otherwise, the open method overwrites it. The close method closes the file after the writeData function is completed.
userInfo = new File("c:/data/info.txt")
userInfo.open("w")
writeData()
userInfo.close()
Example 2. The following example opens a binary file so an application can read data from it. The application uses an if statement to take different actions depending on whether the open statement finds the specified file.
entryGraphic = new File("c:/data/splash.gif")
if (entryGraphic.open("rb") == true)
{
displayProcedure()
}
else
{
errorProcedure()
}
entryGraphic.close()
See also
close method
parse
Method. Returns the number of milliseconds in a date string since January 1, 1970 00:00:00, local time.
Syntax
Date.parse(dateString)
dateString is a string representing a date or a property of an existing object.
Method of
Date
Description
The parse method takes a date string (such as "Dec 25, 1995"), and returns the number of milliseconds since January 1, 1970 00:00:00 (local time). This function is useful for setting date values based on string values, for example in conjunction with the setTime method and the Date object.
Given a string representing a time, parse returns the time value. It accepts the IETF standard date syntax: "Mon, 25 Dec 1995 13:30:00 GMT". It understands the continental US time zone abbreviations, but for general use, use a time zone offset, for example "Mon, 25 Dec 1995 13:30:00 GMT+0430" (4 hours, 30 minutes west of the Greenwich meridian). If you do not specify a time zone, the local time zone is assumed. GMT and UTC are considered equivalent.
Because the parse function is a static method of Date, you always use it as Date.parse()
, rather than as a method of a date object you created.
Examples
If IPOdate is an existing date object, then
IPOdate.setTime(Date.parse("Aug 9, 1995"))
See also
UTC method
parseFloat
Function. Parses a string argument and returns a floating point number.
Syntax
parseFloat(string)
string is a string that represents the value you want to parse.
Description
The parseFloat function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself.
parseFloat parses its argument, a string, and returns a floating point number. If it encounters a character other than a sign ( + or -), numeral (0-9), a decimal point, or an exponent, then it returns the value up to that point and ignores that character and all succeeding characters.
If the first character cannot be converted to a number, parseFloat returns one of the following values:
Examples
The following examples all return 3.14:
parseFloat("3.14")
parseFloat("314e-2")
parseFloat("0.0314E+2")
var x = "3.14"
parseFloat(x)
The following example returns "NaN" or 0:
parseFloat("FF2")
See also
isNaN, parseInt functions
parseInt
Function. Parses a string argument and returns an integer of the specified radix or base.
Syntax
parseInt(string [,radix])
string is a string that represents the value you want to parse.
radix is an integer that represents the radix of the return value.
Description
The parseInt function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself.
The parseInt function parses its first argument, a string, and attempts to return an integer of the specified radix (base). For example, a radix of 10 indicates to convert to a decimal number, 8 octal, 16 hexadecimal, and so on. For radixes above 10, the letters of the alphabet indicate numerals greater than 9. For example, for hexadecimal numbers (base 16), A through F are used.
If parseInt encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point. ParseInt truncates numbers to integer values.
If the radix is not specified or is specified as 0, JavaScript assumes the following:
Examples
The following examples all return 15:
parseInt("F", 16)
parseInt("17", 8)
parseInt("15", 10)
parseInt(15.99, 10)
parseInt("FXX123", 16)
parseInt("1111", 2)
parseInt("15*3", 10)
The following examples all return "NaN" or 0:
parseInt("Hello", 8)
parseInt("0x7", 10)
parseInt("FFF", 10)
Even though the radix is specified differently, the following examples all return 17 because the input string begins with "0x".
parseInt("0x11", 16)
parseInt("0x11", 0)
parseInt("0x11")
See also
isNaN, parseFloat functions
PI
Property. The ratio of the circumference of a circle to its diameter, approximately 3.14159.
Syntax
Math.PI
Property of
Math
Description
Because PI is a constant, it is a read-only property of Math.
Examples
The following example displays the value of pi:
document.write("The value of pi is " + Math.PI)
See also
E, LN2, LN10, LOG2E, LOG10E, SQRT1_2, SQRT2 properties
port
Property. A string indicating the port number used for the server.
Syntax
server.port
Property of
server
Description
The port property specifies a portion of the URL. The port property is a substring of the hostname property. The hostname property is the concatenation of the host and port properties, separated by a colon.
The default value of the port property is 80. When the port property is set to the default, the values of the host and hostname properties are the same.
port is a read-only property.
See Section 3.1 of RFC 1738 (http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html) for complete information about the port.
Examples
See the examples for the server object.
See also
host, hostname, and protocol properties.
pow
Method. Returns base to the exponent power, that is, baseexponent.
Syntax
Math.pow(base, exponent)
base is any numeric expression or a property of an existing object.
exponent is any numeric expression or a property of an existing object.
Method of
Math
Examples
//Displays the value 49
document.write("7 to the power of 2 is " + Math.pow(7,2))
//Displays the value 1024
document.write("<P>2 to the power of 10 is " + Math.pow(2,10))
See also
exp, log methods
project
Object. Contains data for an entire application.
Syntax
To use a project object:
1. project.propertyName
2. project.methodName
Parameters
propertyName is a property that you create.
methodName is one of the methods listed below or a method that you create.
Property of
None
Description
LiveWire creates a project object when an application starts and destroys the project object when the application stops. The typical project object lifetime is days or weeks.
Each client accessing the same application shares the same project object. Use the project object to maintain global data for an entire application. Many clients can access an application simultaneously, and the project object lets these clients share information.
LiveWire creates a set of project objects for each distinct Netscape HTTPD process running on the server. Since you may have several server HTTPD processes running on different port numbers, LiveWire creates a set of project objects for each process.
You can lock the project object to ensure that different clients do not change its properties simultaneously. When one client locks the project object, other clients must wait before they can modify it. See the lock and unlock methods for complete information.
Properties
The project object has no pre-defined properties. You create custom properties to contain project-specific data that is required by an application.
You can create a property for the project object by assigning it a name and a value. For example, you can create a project object property to keep track of the next available Customer ID. Any client that accesses the application without a Customer ID is sequentially assigned one, and the value of the ID is incremented for each initial access.
Methods
Examples
Example 1. This example creates the lastID property and assigns a value to it by incrementing an existing value.
project.lastID = 1 + parseInt(project.lastID, 10)
Example 2. This example increments the value of the lastID property and uses it to assign a value to the customerID property.
project.lock()
project.lastID = 1 + parseInt(project.lastID, 10)
client.customerID = project.lastID
project.unlock()
In the previous example, notice that the project object is locked while the CustomerID property is assigned, so no other client can attempt to change the lastID property at the same time.
See also
client, request, and server objects
protocol (request object)
Property. Provides the HTTP protocol level supported by the client's software.
Syntax
request.protocol
Property of
request
Description
For HTTP 1.0, the protocol value is "HTTP/1.0". Use the protocol property to determine the proper response to a request.
protocol is a read-only property.
Examples
In the following example, the currentProtocol() function executes if request.protocol evaluates to "HTTP/1.0".
<SERVER>
if (request.protocol=="HTTP/1.0"
currentProtocol()
else
unknownProtocol()
</SERVER>
See also
agent, ip, and method properties
protocol (server object)
Property. A string indicating the communication protocol used by the server.
Syntax
server.protocol
Property of
server
Description
The protocol property specifies the beginning of the URL, up to and including the first colon. The protocol indicates the access method of the URL. For example, a protocol of "http:" specifies Hypertext Transfer Protocol.
protocol is a read-only property.
The protocol property represents the scheme name of the URL. See Section 2.1 of RFC 1738 (http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.html) for complete information about the protocol.
Examples
See the examples for the server object.
See also
host, hostname, and port properties