majorErrorCode

Method. Returns the major error code returned by the database server.

Syntax

database.majorErrorCode()

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 majorErrorCode method returns additional information about the failure.

The majorErrorCode method returns the major error code returned by the database server or ODBC. For server errors, this value typically corresponds to the server's SQLCODE.

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 majorErrorCode.

Examples

This example updates the rentals table within a transaction. The updateRow method assigns a database status code to the statusCode variable to indicate whether the method is successful.

If updateRow succeeds, the value of statusCode is 0, and the transaction is committed. If updateRow returns a statusCode value of either 5 or 7, the values of majorErrorCode, majorErrorMessage, minorErrorCode, and minorErrorMessage are displayed. If statusCode is set to any other value, the errorRoutine function is called.

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() }

See also

majorErrorMessage, minorErrorCode, and minorErrorMessage methods

majorErrorMessage

Method. Returns the major error message returned by the database server.

Syntax

database.majorErrorMessage()

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 majorErrorMessage method returns additional information about the failure.

The majorErrorMessage method returns the major error message returned by the database server or ODBC.

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 majorErrorMessage.

Examples

See the example for the majorErrorCode method.

See also

majorErrorCode, minorErrorCode, and minorErrorMessage methods

Math

Object. A built-in object that has properties and methods for mathematical constants and functions. For example, the Math object's PI property has the value of pi.

Syntax

To use a Math object:

1. Math.propertyName
2. Math.methodName(parameters)

Parameters

propertyName is one of the properties listed below.

methodName is one of the methods listed below.

Property of

None.

Description

The Math object is a built-in JavaScript object.

You reference the constant PI as 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)
}

Properties

Methods

  • abs
  • acos
  • asin
  • atan
  • ceil
  • cos
  • exp
  • floor
  • log
  • max
  • min
  • pow
  • random
  • round
  • sin
  • sqrt
  • tan

    Event handlers

  • None. Built-in objects do not have event handlers.

    Examples

    See the examples for the individual properties and methods.

    max

    Method. Returns the greater of two numbers.

    Syntax

    Math.max(number1, number2)
    

    Parameters

    number1 and number2 are any numeric arguments or the properties of existing objects.

    Method of

    Math

    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:

  • r[b] opens a file for reading. If the file exists, the method succeeds and returns true; otherwise, the method fails and returns false.
  • w[b] opens a file for writing. If the file does not already exist, it is created; otherwise, it is overwritten. This method always succeeds and returns true.
  • a[b] opens a file for appending (writing at the end of the file). If the file does not already exist, it is created. This method always succeeds and returns true.
  • r+[b] opens a file for reading and writing. If the file exists, the method succeeds and returns true; otherwise, the method fails and returns false. Reading and writing commence at the beginning of the file. When writing, characters at the beginning of the file are overwritten.
  • w+[b] opens a file for reading and writing. If the file does not already exist, it is created; otherwise, it is overwritten. This method always succeeds and returns true.
  • a+[b] opens a file for reading and appending. If the file does not already exist, it is created. This method always succeeds and returns true. Reading and appending commence at the end of the file. If you use the b parameter when you specify the mode, LiveWire opens the file as a binary file. If you do not use the b parameter, LiveWire opens the file as a text file. The b parameter is available only on Windows platforms.

    When your application is finished with a file, you should close the file by calling the close method.

    The open method returns true if it is successful; otherwise, it returns false.

    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:

  • 0 on Windows platforms.
  • "NaN" on any other platform, indicating that the value is not a number. For arithmetic purposes, the "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseFloat is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".

    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:

  • If the input string begins with "0x", the radix is 16 (hexadecimal).
  • If the input string begins with "0", the radix is 8 (octal).
  • If the input string begins with any other value, the radix is 10 (decimal). If the first character cannot be converted to a number, parseFloat returns one of the following values:

  • 0 on Windows platforms.
  • "NaN" on any other platform, indicating that the value is not a number. For arithmetic purposes, the "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseInt is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".

    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

  • lock
  • unlock

    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