Math.tan(number)
Description
The tan method returns a numeric value which represents the tangent of the angle.
Examples
//Displays the value 0.9999999999999999
document.write("The tangent of pi/4 radians is " +
Math.tan(Math.PI/4))
//Displays the value 0
document.write("<P>The tangent of 0 radians is " +
Math.tan(0))
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 will give 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 lower case.
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 lower case. toLowerCase does not affect the value of stringName itself.
Examples
The following examples both yield "alphabet".
var upperText="ALPHABET"
document.write(upperText.toLowerCase())
"ALPHABET".toLowerCase()
See also
toUpperCase method
toUpperCase
Method. Returns the calling string value converted to upper case.
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 upper case. toUpperCase does not affect the value of stringName itself.
Examples
The following examples both yield "ALPHABET".
var lowerText="alphabet"
document.write(lowerText.toUpperCase())
"alphabet".toUpperCase()
See also
toLowerCase method
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 an accidental deadlock situation.
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
Description
The updateRow method lets you use values in the current row of an updateable cursor to modify a table. See the cursor method for information about creating an updateable cursor.
Assign values to columns in the current row of the cursor, 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 0; otherwise, it returns a non-zero integer to indicate the reason it failed. See Interpreting 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 and 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 0-11.
date is a day of the month between 1-31.
hrs is hours between 0-23.
min is minutes between 0-59.
sec is seconds between 0-59.
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 is a top-level LiveWire function that is not associated with any object.
The write function causes LiveWire to generate HTML that is sent to the client. The client interprets this dynamically 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. You can control when data is sent to the client by using the flush function.
Do not confuse the write method of the File object with the top-level write function. The write function outputs data to the client browser; 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 57, 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 top-level 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, read, writeln, and writeByte methods
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, readByte, write, and writeln methods
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" ("\r\n" 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, readln, write, and writeByte methods
writeURL
Function. Creates a URL that is compatible with dynamic URL encoding.
Syntax
writeURL(urlValue)
Parameters
urlValue is the name of a property containing a dynamically generated URL.
Description
The writeURL function is a top-level LiveWire function that is not associated with any object.
Use writeURL to generate a URL when an application maintains URL information in either of the following ways:
See Techniques for maintaining the client object for information about URL encoding.
Examples
The following example uses writeURL to generate a URL within an <A> tag. The value of the URL is encoded in the nextPage property of the client object.
<A HREF='writeURL(project.nextPage)'>
If the URL is not encoded, you can specify the HREF without the writeURL function, as follows:
<A HREF='project.nextPage'>