server

Object. Contains global data for the entire server.

Syntax

To use a server object:

1. server.propertyName
2. server.methodName

Parameters

propertyName is one of the properties listed below or 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 server object when the server starts and destroys it when the server stops. Every application on a server shares the same server object. Use the server object to maintain global data for the entire server. Many applications can run on a server simultaneously, and the server object lets them share information.

LiveWire creates a server object for each distinct Netscape HTTPD process running on the server.

The properties listed below are read-only properties that are initialized automatically when a server object is created. These properties provide information about the server process. In addition to these predefined properties, you can create custom properties.

You can lock the server object to ensure that different applications do not change its properties simultaneously. When one application locks the server object, other applications must wait before they can modify it. See the lock and unlock methods for complete information.

Properties

Methods

Examples

The following example displays the values of the predefined server object properties:

<P>server.host = <SERVER>write(server.host);</SERVER>
<BR>server.hostname = <SERVER>write(server.hostname);</SERVER>
<BR>server.protocol = <SERVER>write(server.protocol);</SERVER>
<BR>server.port = <SERVER>write(server.port);</SERVER>
The preceding code displays information such as the following:

server.host = www.myWorld.com
server.hostname = www.myWorld.com:85
server.protocol = http:
server.port = 85

See also

client, project, request objects

setDate

Method. Sets the day of the month for a specified date.

Syntax

dateObjectName.setDate(dayValue)

Parameters

dateObjectName is either the name of a Date object or a property of an existing object.

dayValue is an integer from one to thirty-one or a property of an existing object, representing the day of the month.

Method of

Date

Examples

The second statement below changes the day for theBigDay to the 24th of July from its original value.

theBigDay = new Date("July 27, 1962 23:30:00")
theBigDay.setDate(24)

See also

getDate method

setHours

Method. Sets the hours for a specified date.

Syntax

dateObjectName.setHours(hoursValue)

Parameters

dateObjectName is either the name of a Date object or a property of an existing object.

hoursValue is an integer between zero and twenty-three or a property of an existing object, representing the hour.

Method of

Date

Examples

theBigDay.setHours(7)

See also

getHours method

setMinutes

Method. Sets the minutes for a specified date.

Syntax

dateObjectName.setMinutes(minutesValue)

Parameters

dateObjectName is either the name of a Date object or a property of an existing object.

minutesValue is an integer between zero and fifty-nine or a property of an existing object, representing the minutes.

Method of

Date

Examples

theBigDay.setMinutes(45)

See also

getMinutes method

setMonth

Method. Sets the month for a specified date.

Syntax

dateObjectName.setMonth(monthValue)

Parameters

dateObjectName is either the name of a Date object or a property of an existing object.

monthValue is an integer between zero and eleven (representing the months January through December) or a property of an existing object.

Method of

Date

Examples

theBigDay.setMonth(6)

See also

getMonth method

setPosition

Method. Positions a pointer in an open file.

Syntax

fileObjectName.setPosition(position [,reference])

Parameters

fileObjectName is the name of a File object.

position is an integer indicating where to position the pointer.

reference is an integer that indicates a reference point, according to the list below.

Method of

File

Description

Use the setPosition method to reposition the pointer in a file. See the File object for a description of the pointer.

The position argument is a positive or negative integer that moves the pointer the specified number of bytes relative to the reference argument. Position zero represents the beginning of a file. The end of a file is indicated by fileObjectName.getLength().

The optional reference argument is one of the following values, indicating the reference point for the position:

  • 0: relative to beginning of file.
  • 1: relative to current position.
  • 2: relative to end of file.
  • Other (or unspecified): relative to beginning of file.

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

    Examples

    The following examples reference the file info.txt, which contains the string "Hello World." The length of info.txt is eleven bytes. The first example moves the pointer from the beginning of the file, and the second example moves the pointer to the same location by navigating relative to the end of the file. Both examples display the following information:

    The position is 10
    The next character is d
    
    Example 1. This example moves the pointer from the beginning of the file to offset ten. Because no value for reference is supplied, LiveWire assumes it is zero.

    dataFile = new File("c:/data/info.txt")
    dataFile.open("r")
    
    dataFile.setPosition(10)
    write("The position is " + dataFile.getPosition() + "<BR>")
    write("The next character is " + dataFile.read(1) + "<P>")
    
    dataFile.close()
    
    Example 2. This example moves the pointer from the end of the file to offset ten.

    dataFile = new File("c:/data/info.txt")
    dataFile.open("r")
    
    dataFile.setPosition(-1,2)
    write("The position is " + dataFile.getPosition() + "<BR>")
    write("The next character is " + dataFile.read(1) + "<P>")
    
    dataFile.close()
    

    See also

    eof, getPosition, open methods

    setSeconds

    Method. Sets the seconds for a specified date.

    Syntax

    dateObjectName.setSeconds(secondsValue)
    

    Parameters

    dateObjectName is either the name of a Date object or a property of an existing object.

    secondsValue is an integer between zero and fifty-nine or a property of an existing object.

    Method of

    Date

    Examples

    theBigDay.setSeconds(30)
    

    See also

    getSeconds method

    setTime

    Method. Sets the value of a Date object.

    Syntax

    dateObjectName.setTime(timevalue) 
    

    Parameters

    dateObjectName is either the name of a Date object or a property of an existing object.

    timevalue is an integer or a property of an existing object, representing the number of milliseconds since the epoch (1 January 1970 00:00:00).

    Method of

    Date

    Description

    Use the setTime method to help assign a date and time to another Date object.

    Examples

    theBigDay = new Date("July 1, 1999")
    sameAsBigDay = new Date()
    sameAsBigDay.setTime(theBigDay.getTime())
    

    See also

    getTime method

    setYear

    Method. Sets the year for a specified date.

    Syntax

    dateObjectName.setYear(yearValue)
    

    Parameters

    dateObjectName is either the name of a Date object or a property of an existing object.

    yearValue is an integer greater than 1900 or a property of an existing object.

    Method of

    Date

    Examples

    theBigDay.setYear(96)
    

    See also

    getYear method

    sin

    Method. Returns the sine of a number.

    Syntax

    Math.sin(number)
    

    Parameters

    number is a numeric expression or a property of an existing object, representing the size of an angle in radians.

    Method of

    Math

    Description

    The sin method returns a numeric value between -1 and one, which represents the sine of the argument.

    Examples

    The following function returns the sine of the variable x:

    function getSine(x) {
       return Math.sin(x)
    }
    
    If you pass getSine the value Math.PI/2, it returns 1.

    See also

    acos, asin, atan, cos, tan methods

    small

    Method. Causes a string to be displayed in a small font, as if it were in a SMALL tag.

    Syntax

    stringName.small()
    

    Parameters

    stringName is any string or a property of an existing object.

    Method of

    string

    Description

    Use the small method with the write or writeln methods to format and display a string in a document. In LiveWire, use the write function to display the string.

    Examples

    The following example uses string methods to change the size of a string:

    var worldString="Hello, world"
    
    document.write(worldString.small())
    document.write("<P>" + worldString.big())
    document.write("<P>" + worldString.fontsize(7))
    
    The previous example produces the same output as the following HTML:

    <SMALL>Hello, world</SMALL>
    <P><BIG>Hello, world</BIG>
    <P><FONTSIZE=7>Hello, world</FONTSIZE>
    
    In LiveWire, you can generate this HTML by calling the write function instead of using document.write.

    See also

    big, fontsize methods

    SQLTable

    Method. Displays the result of a SQL SELECT statement in an HTML table.

    Syntax

    database.SQLTable("sqlStatement")
    

    Parameters

    sqlStatement is an expression that evaluates to a SQL SELECT statement supported by the database server.

    Method of

    database

    Description

    The SQLTable method is the easiest way to display the output of a database query. The SQLTable method displays the results of a database query in an HTML table.

    The SQLTable method does not let you explicitly control the format of the output. To customize the appearance of the output, use a database cursor. See the cursor method for information about creating a cursor.

    Examples

    In the following example, the connect method opens the sample database included with LiveWire, and the SQLTable method queries the videos table. The SQL SELECT statement provided as an argument to the SQLTable method returns all the rows in the videos table sorted by the values in the title field.

    database.connect("INFORMIX", "ol_alpha", "guest", "guest", "livewire")
    database.SQLTable("SELECT * FROM VIDEOS ORDER BY TITLE")
    
    The call to SQLTable generates the following HTML:

    <TABLE BORDER>
    <TR>
    <TH>title</TH>
    <TH>id</TH>
    <TH>year</TH>
    <TH>category</TH>
    <TH>quantity</TH>
    <TH>numonhand</TH>
    <TH>synopsis</TH>
    </TR>
    <TR>
    <TD>10</TD>
    <TD>3</TD>
    <TD>1979</TD>
    <TD>Comedy</TD>
    <TD>5</TD>
    <TD>4</TD>
    <TD>Middle aged man recaptures his youth in Mexico, and discovers he 
    doesn't know what to do with it.</TD>
    </TR>
    <TR>
    <TD>A Boy and His Dog</TD>
    ...
    

    See also

    cursor method, execute method

    sqrt

    Method. Returns the square root of a number.

    Syntax

    Math.sqrt(number)
    

    Parameters

    number is any non-negative numeric expression or a property of an existing object.

    Method of

    Math

    Description

    If the value of number is outside the required range, sqrt returns zero.

    Examples

    The following function returns the square root of the variable x:

    function getRoot(x) {
       return Math.sqrt(x)
    }
    
    If you pass getRoot the value nine, it returns three; if you pass it the value two, it returns 1.414213562373095.

    SQRT1_2

    Property. The square root of one-half; equivalently, one over the square root of two, approximately 0.707.

    Syntax

    Math.SQRT1_2
    

    Property of

    Math

    Description

    Because SQRT1_2 is a constant, it is a read-only property of Math.

    Examples

    The following function returns one over the square root of two:

    function getRoot1_2() {
       return Math.SQRT1_2
    }
    

    See also

    E, LN2, LN10, LOG2E, LOG2E, PI, SQRT2 properties

    SQRT2

    Property. The square root of two, approximately 1.414.

    Syntax

    Math.SQRT2
    

    Property of

    Math

    Description

    Because SQRT2 is a constant, it is a read-only property of Math.

    Examples

    The following function returns the square root of two:

    function getRoot2() {
       return Math.SQRT2
    }
    

    See also

    E, LN2, LN10, LOG2E, LOG2E, PI, SQRT1_2 properties

    strike

    Method. Causes a string to be displayed as struck-out text, as if it were in a STRIKE tag.

    Syntax

    stringName.strike()
    

    Parameters

    stringName is any string or a property of an existing object.

    Method of

    string

    Description

    Use the strike method with the write or writeln methods to format and display a string in a document. In LiveWire, use the write function to display the string.

    Examples

    The following example uses string methods to change the formatting of a string:

    var worldString="Hello, world"
    
    document.write(worldString.blink())
    document.write("<P>" + worldString.bold())
    document.write("<P>" + worldString.italics())
    document.write("<P>" + worldString.strike())
    
    The previous example produces the same output as the following HTML:

    <BLINK>Hello, world</BLINK>
    <P><B>Hello, world</B>
    <P><I>Hello, world</I>
    <P><STRIKE>Hello, world</STRIKE>
    
    In LiveWire, you can generate the above HTML by calling the write function instead of using document.write.

    See also

    blink, bold, italics methods

    string

    Object. A series of characters.

    Syntax

    To use a string object:

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

    Parameters

    stringName is the name of a string variable.

    propertyName is one of the properties listed below.

    methodName is one of the methods listed below.

    Property of

    None

    Description

    The string object is a built-in JavaScript object.

    A string can be represented as a literal enclosed by single or double quotation marks; for example, "Netscape" or 'Netscape.'

    Properties

    The string object has one property, length, an integer reflecting the length of the string.

    Methods

    The string object has the following methods:

    Event handlers

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

    Examples

    The following statement creates a string variable:

    var last_name = "Schaefer"
    
    The following statements evaluate to eight, "SCHAEFER," and "schaefer":

    last_name.length
    last_name.toUpperCase()
    last_name.toLowerCase()
    

    stringToByte

    Method. Converts the first character of a string into a number that represents a byte.

    Syntax

    File.stringToByte(string)
    

    Parameters

    string is a JavaScript string.

    Method of

    File

    Description

    Use the stringToByte and byteToString methods to convert data between binary and ASCII formats. The stringToByte method converts the first character of its string argument into a number that represents a byte. This is a static method of the File object; you call this method without specifying the name of a specific File object.

    If this method succeeds, it returns the numeric value of the first character of the input string; if it fails, it returns zero.

    Examples

    In the following example, the stringToByte method is passed "Hello" as an input argument. The method converts the first character, "H," into a numeric value representing a byte.

    write("The stringToByte value of Hello = " +
       File.stringToByte("Hello") + "<BR>")
    write("Returning that value to byteToString = " +
       File.byteToString(File.stringToByte("Hello")) + "<P>")
    
    The previous example displays the following information:

    The stringToByte value of Hello = 72
    Returning that value to byteToString = H
    

    See also

    byteToString method

    sub

    Method. Causes a string to be displayed as a subscript, as if it were in a SUB tag.

    Syntax

    stringName.sub()
    

    Parameters

    stringName is any string or a property of an existing object.

    Method of

    string

    Description

    Use the sub method with the write or writeln methods to format and display a string in a document. In LiveWire, use the write function to generate the HTML.

    Examples

    The following example uses the sub and sup methods to format a string:

    var superText="superscript"
    var subText="subscript"
    
    document.write("This is what a " + superText.sup() + " looks like.")
    document.write("<P>This is what a " + subText.sub() + " looks like.")
    
    The previous example produces the same output as the following HTML:

    This is what a <SUP>superscript</SUP> looks like.
    <P>This is what a <SUB>subscript</SUB> looks like.
    
    In LiveWire, you can generate the above HTML by calling the write function instead of using document.write.

    See also

    sup method

    substring

    Method. Returns a subset of a string object.

    Syntax

    stringName.substring(indexA, indexB)
    

    Parameters

    stringName is any string or a property of an existing object.

    indexA is any integer from zero to stringName.length - 1, or a property of an existing object.

    indexB is any integer from zero to stringName.length - 1, or a property of an existing object.

    Method of

    string

    Description

    Characters in a string are indexed from left to right. The index of the first character is zero, and the index of the last character is stringName.length - 1.

    If indexA is less than indexB, the substring method returns the subset starting with the character at indexA and ending with the character before indexB. If indexA is greater than indexB, the substring method returns the subset starting with the character at indexB and ending with the character before indexA. If indexA is equal to indexB, the substring method returns the empty string.

    Examples

    The following example uses substring to display characters from the string "Netscape":

    var anyString="Netscape"
    
    //Displays "Net"
    document.write(anyString.substring(0,3))
    document.write(anyString.substring(3,0))
    //Displays "cap"
    document.write(anyString.substring(4,7))
    document.write(anyString.substring(7,4))
    
    In LiveWire, you can display the same output by calling the write function instead of using document.write.

    sup

    Method. Causes a string to be displayed as a superscript, as if it were in a SUP tag.

    Syntax

    stringName.sup()
    

    Parameters

    stringName is any string or a property of an existing object.

    Method of

    string

    Description

    Use the sup method with the write or writeln methods to format and display a string in a document. In LiveWire, use the write function to generate the HTML.

    Examples

    The following example uses the sub and sup methods to format a string:

    var superText="superscript"
    var subText="subscript"
    
    document.write("This is what a " + superText.sup() + " looks like.")
    document.write("<P>This is what a " + subText.sub() + " looks like.")
    
    The previous example produces the same output as the following HTML:

    This is what a <SUP>superscript</SUP> looks like.
    <P>This is what a <SUB>subscript</SUB> looks like.
    
    In LiveWire, you can generate the above HTML by calling the write function instead of using document.write.

    See also

    sub method