## tan

Method. Returns the tangent of a number.

#### Syntax

    Math.tan(number)

#### Parameters

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

#### Method of

Math

#### Description

The tan method returns a numeric value that represents the tangent of the angle.

#### Examples

The following function returns the tangent of the variable x:

    function getTan(x) {

       return Math.tan(x)

    }

If you pass getTan the value Math.PI/4, it returns 0.9999999999999999.

#### See also

acos, asin, atan, cos, sin methods

## toGMTString

Method. Converts a date to a string, using the Internet GMT conventions.

#### Syntax

    dateObjectName.toGMTString()

#### Parameters

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

#### Method of

Date

#### Description

The exact format of the value returned by toGMTString varies according to the platform.

#### Examples

In the following example, today is a Date object:

    today.toGMTString()

In this example, the toGMTString method converts the date to GMT (UTC) using the operating system's time-zone offset and returns a string value that is similar to the following form. The exact format depends on the platform.

    Mon, 18 Dec 1995 17:28:35 GMT

#### See also

toLocaleString method

## toLocaleString

Method. Converts a date to a string, using the current locale's conventions.

#### Syntax

    dateObjectName.toLocaleString()

#### Parameters

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

#### Method of

Date

#### Description

If you are trying to pass a date using toLocaleString, be aware that different locales assemble the string in different ways. Using methods such as getHours, getMinutes, and getSeconds gives more portable results.

#### Examples

In the following example, today is a Date object:

    today.toLocaleString()

In this example, toLocaleString returns a string value that is similar to the following form. The exact format depends on the platform.

    12/18/95 17:28:35

#### See also

toGMTString method

## toLowerCase

Method. Returns the calling string value converted to lowercase.

#### Syntax

    stringName.toLowerCase()

#### Parameters

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

#### Method of

string

#### Description

The toLowerCase method returns the value of stringName converted to lowercase. toLowerCase does not affect the value of stringName itself.

#### Examples

The following example displays the lowercase string "alphabet":

    var upperText="ALPHABET"

    document.write(upperText.toLowerCase())

In LiveWire, you can generate the same output by calling the write function instead of using `document.write`.

#### See also

toUpperCase method

## toUpperCase

Method. Returns the calling string value converted to uppercase.

#### Syntax

    stringName.toUpperCase()

#### Parameters

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

#### Method of

string

#### Description

The toUpperCase method returns the value of stringName converted to uppercase. toUpperCase does not affect the value of stringName itself.

#### Examples

The following example displays the string "ALPHABET":

    var lowerText="alphabet"

    document.write(lowerText.toUpperCase())

In LiveWire, you can generate the same output by calling the write function instead of using `document.write`.

#### See also

toLowerCase method

## unescape

Function. Returns the ASCII string for the specified value.

#### Syntax

    unescape("string")

#### Parameters

string is a string or a property of an existing object, containing characters in the form "%hex", where hex is a hexadecimal value.

#### Description

Use unescape to decode name/value pairs in URLs. The string returned by the unescape function is a series of characters in the ISO Latin-1 character set. The unescape function is a top-level LiveWire function that is not associated with any object.

#### Examples

In the following example, val1 has been passed to the request object as a hexadecimal value. The statement assigns the decoded value of val1 to myValue.

    myValue = unescape(request.val1)

#### See also

escape function

## unlock

Method. Unlocks the project or server object.

#### Syntax

    1. project.unlock()

    2. server.unlock()

#### Method of

project, server

#### Description

You can lock the project or server object to ensure that different clients do not change its properties simultaneously. When an application locks an object, other client requests must wait before they can modify or lock the object.

It is good programming practice to call the unlock method and release an object after calling the lock method. However, LiveWire automatically unlocks an object after the completion of each request to prevent accidental deadlock.

#### Examples

See Example 2 of the project object for an example of using the unlock method.

#### See also

lock method

## updateRow

Method. Updates the current row of a table with values from the current row in a cursor.

#### Syntax

    cursorName.updateRow(tableName)

#### Parameters

cursorName is the name of a cursor object.

tableName is the name of a database table.

#### Method of

cursor object

#### Description

The updateRow method lets you use values in the current row of an updatable cursor to modify a table. See the cursor method for information about creating an updatable cursor. Before performing an updateRow, you must perform at least one next with the cursor so the current row is set to a row.

Assign values to columns in the current row of the cursor, and then use the updateRow method to update the current row of the table specified by the tableName parameter. Column values that are not explicitly assigned are not changed by the updateRow method.

The updateRow method returns a status code based on a database server message to indicate whether the method completed successfully. If successful, the method returns a zero; otherwise, it returns a nonzero integer to indicate the reason it failed. See "Database status codes." for an explanation of the individual status codes.

#### Examples

This example uses updateRow to update the returndate column of the rentals table. The values of customerID and videoID are passed into the cursor method as properties of the request object. When the videoReturn cursor object opens, the next method navigates to the only record in the answer set and updates the value in the returnDate field.

    // Create a Date object with the value of today's date

    today = new Date()

    // Create a cursor with the rented video in the answer set

    videoReturn = database.cursor("SELECT * FROM rentals WHERE

       customerId = " + request.customerID + " AND

       videoId = " + request.videoID, true)

    // Position the pointer on the first row of the cursor

    videoReturn.next()

    // Assign today's date to the returndate column

    videoReturn.returndate = today

    // Update the row

    videoReturn.updateRow("rentals")

#### See also

deleteRow, insertRow methods

## UTC

Method. Returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, Universal Coordinated Time (GMT).

#### Syntax

    Date.UTC(year, month, day [, hrs] [, min] [, sec])

#### Parameters

year is a year after 1900.

month is a month between zero and eleven.

date is a day of the month between one and thirty-one.

hrs is hours between zero and twenty-three.

min is minutes between zero and fifty-nine.

sec is seconds between zero and fifty-nine.

#### Method of

Date

#### Description

UTC takes comma-delimited date parameters and returns the number of milliseconds since January 1, 1970, 00:00:00, Universal Coordinated Time (GMT).

Because UTC is a static method of Date, you always use it as `Date.UTC()`, rather than as a method of a Date object you created.

#### Examples

The following statement creates a Date object using GMT instead of local time:

    gmtDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0))

#### See also

parse method

## write function

Function. Generates HTML based on an expression and sends it to the client.

#### Syntax

    write(expression)

#### Parameters

expression is a valid JavaScript expression.

#### Description

The write function causes LiveWire to generate HTML that is sent to the client. The client interprets this generated HTML the same as static HTML.

To improve performance, LiveWire buffers the output of the write function and sends it to the client in large blocks of at most 64Kbytes in size. You can control when data are sent to the client by using the flush function.

The write function is a top-level LiveWire function that is not associated with any object. Do not confuse the write method of the File object with the write function. The write function outputs data to the client; the write method outputs data to a physical file on the server.

#### Examples

In the following example, the write function is passed a string, concatenated with a variable, concatenated with an HTML BR tag:

    write("The operation returned " + returnValue + "<BR>")

If returnValue is fifty-seven, this example displays

    The operation returned 57

#### See also

flush function

## write method

Method. Writes data from a string to a file on the server.

#### Syntax

    fileObjectName.write(string)

#### Parameters

fileObjectName is the name of a File object.

string is a JavaScript string.

#### Method of

File

#### Description

The write method writes the string specified as string to the file specified as fileObjectName. This method returns true if it is successful; otherwise, it returns false.

Use the write method to write data to a text file; use the writeByte method to write data to a binary file. You can use the read method to read data from a file to a string for use with the write method.

Do not confuse the write method of the File object with the write function. The write function outputs data to the client browser; the write method outputs data to a physical file on the server.

#### Examples

This example creates a copy of a text file, one character at a time. In this example, a while loop executes until the pointer is positioned past the end of the file. While the pointer is not positioned past the end of the file, the read method reads the current character from the source file, and the write method writes it to the target file. The last read method positions the pointer past the end of the file, ending the while loop. See the File object for a description of the pointer.

    // Create the source File object

    source = new File("c:/data/source.txt")

    // If the source file opens successfully, create a target file

    if (source.open("r")) {

       target = new File("c:/data/target.txt")

       target.open("w")

    // Copy the source file to the target

       while (!source.eof()) {

          data = source.read(1)

          target.write(data);

       }

       source.close();

    }

       target.flush()

       target.close()

#### See also

flush method, read method, writeByte method, writeln method

## writeByte

Method. Writes a byte of data to a binary file on the server.

#### Syntax

    fileObjectName.writeByte(number)

#### Parameters

fileObjectName is the name of a File object.

number is a number that specifies a byte of data.

#### Method of

File

#### Description

The writeByte method writes a byte that is specified as number to a file that is specified as fileObjectName. This method returns true if it is successful; otherwise, it returns false.

Use the writeByte method to write data to a binary file; use the write method to write data to a text file. You can use the readByte method to read bytes of data from a file to numeric values for use with the writeByte method.

#### Examples

See the example for the readByte method.

#### See also

flush method, readByte method, write method, writeln method

## writeln

Method. Writes a string and a carriage return to a file on the server.

#### Syntax

    fileObjectName.writeln(string)

#### Parameters

fileObjectName is the name of a File object.

string is a JavaScript string.

#### Method of

File

#### Description

The writeln method writes the string specified as string to the file specified as fileObjectName. Each string is followed by the carriage return/line feed character "n" ("rn" on Windows platforms). This method returns true if the write is successful; otherwise, it returns false.

Use the writeln method to write data to a text file; use the writeByte method to write data to a binary file. You can use the readln method to read data from a file to a string for use with the writeln method.

#### Examples

This example creates a copy of a text file, one line at a time. In this example, a while loop executes until the pointer is positioned past the end of the file. While the pointer is not positioned past the end of the file, the readln method reads the current line from the source file, and the writeln method writes it to the target file. The last readln method positions the pointer past the end of the file, ending the while loop. See the File object for a description of the pointer.

    // Create the source File object

    source = new File("c:/data/source.txt")

    // If the source file opens successfully, create a target file

    if (source.open("r")) {

       target = new File("c:/data/target.txt")

       target.open("w")

    // Copy the source file to the target

       while (!source.eof()) {

          data = source.readln()

          target.writeln(data);

       }

       source.close();

    }

       target.close()

Note that the readln method ignores the carriage return/line feed characters when it reads a line from a file. The writeln method appends these characters to the string that it writes.

#### See also

flush method, readln method, write method, writeByte method