1. server.propertyName 2. server.methodName
<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>This code displays information such as the following:
server.host = www.myWorld.com server.hostname = www.myWorld.com:85 server.protocol = http: server.port = 85
dateObjectName.setDate(dayValue)
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 0 and 23 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 0 and 59 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 0 and 11 (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 0 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:
Examples
The following examples reference the file info.txt which contains the string "Hello World". The length of info.txt is 11 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 10. Because no value for reference is supplied, LiveWire assumes it is 0.
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 10.
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, and 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 0 and 59 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 1, which represents the sine of the angle.
Examples
//Displays the value 1
document.write("The sine of pi/2 radians is " +
Math.sin(Math.PI/2))
//Displays the value 1.224606353822377e-016
document.write("<P>The sine of pi radians is " +
Math.sin(Math.PI))
//Displays the value 0
document.write("<P>The sine of 0 radians is " +
Math.sin(0))
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.
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>
See also
big, fontsize methods
SQLTable
Method. Displays the result of an SQL SELECT statement as if it were in an HTML table.
Syntax
database.SQLTable("sqlStatement")
Parameters
sqlStatement is an expression that evaluates to an 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 each row and column that the query returns as if it were a row and column 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, create a display function using 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 previous example produces the same output as 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 and execute methods
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 suggested range, the return value is always 0.
Examples
//Displays the value 3
document.write("The square root of 9 is " + Math.sqrt(9))
//Displays the value 1.414213562373095
document.write("<P>The square root of 2 is " + Math.sqrt(2))
//Displays the value 0 because the argument is out of range
document.write("<P>The square root of -1 is " + Math.sqrt(-1))
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 example displays 1 over the square root of 2:
document.write("1 over the square root of 2 is " + 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 example displays the square root of 2:
document.write("The square root of 2 is " + 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.
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>
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 quotes; for example, "Netscape" or 'Netscape'.
Properties
Methods
Event handlers
Examples
The following statement creates a string variable.
var last_name = "Schaefer"
The following statements evaluate to 8, "SCHAEFER", and "schaefer":
last_name.length
last_name.toUpperCase()
last_name.toLowerCase()
See also
text object and textarea object
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>")
This 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.
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.
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 0 to stringName.length - 1, or a property of an existing object.
indexB is any integer from 0 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 0, 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))
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.
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.
See also
sub method