The description Each of the frames of this document is created with the help by last version of the designer "Michael" and demonstrates opportunities of the designer.
Purpose This operative help on JAVA is intended for application and study of language of the scripts VBS. The application of language is carried out by an insert of fragments of language and examples in the text of the edited script and illustrative performance of examples. For study of language the elements of language, fragments, examples and comment are given.
The order of application
Opening of this window. This window of the operative help on language JAVA opens:
when on a field of the designer the window of editing of the script, or HTML-code is opened;
and when is marked the second of radio-switches;
and when the cursor of the mouse is placed on a place of an insert of a fragment or example;
and when is pressed on the keyboard "Alt";
and when the click on a place of an insert is made.
The description of a window Before you a window. It consists of 3 frames:
The top frame is intended for return to the looken up topics. For transition on the looken up topics forward or back under the list, click buttons "forward", "back". For any transition open the list and click the necessary topic.
The left frame contains topics as the list. By search, viewing choose the topic, necessary to you, and click it. The topic will appear in the right frame and its heading will be inserted into the list of the looken up topics.
Right frame represents the contents of topics. Each topic can contain the references to other topics. Click the underlined black text and there will be a necessary topic, and its heading will be inserted into the list of the looken up topics. For inclusion of a topic in the list of the looken up topics, with viewing in the right frame by scrolling, click heading of a topic.
Insert of fragments and examples in the script. The elements of language ready to an insert in the script are submitted as dark blue italics. For their insert click them. The examples, which can be inserted into the text of the script, are placed in frameworks. The idea about application of fragments and examples in practical programming and study of language is, that you insert them into the text of your script and correct them so, that they corresponded to that is necessary.It means: change of names variable, replacement of constant and other.
Illustrative performance of examples. To be sure that the examples work, and to look results of this work, and to estimate them, the practical examples are given. Their texts are placed in frameworks. For performance of an example place the cursor inside of a framework and press "Enter". The example will be executed. Estimate results. If they correspond to needs of your script, place the cursor inside of a framework and click. The text of an example will be inserted into the text of the edited script.
Note Some examples in frameworks are given only for an insert. The place of click for an insert is marked by a symbol ¶. Do not trouble itself with removal of this symbol, it is erased automatically.
The tag SCRIPT
All texts of the scripts should be inside this tags, if you work in a window of editing of "head" or "tags/scripts" (light-blue fields) of object "HTML". Therefore the insert of the scripts-codes in the text SCRIPT is carried out automatically. The texts of the scripts of processing of events can be in scripts.
Examples of the tag:
If to place the scripts inside of the tag HEAD, that script will be loaded before its performance.
PROCEDURES JAVA:
Functions in JAVA
The functions are the programs carrying out actions and called from various parts of the different scripts by transfer of parameters and return of value.
Without parameters
The description
Call dev1();
With parameters
The description
Call dev5=dev1(1,2);
Properties of function:
arguments - The reference to an array, containing arguments. Property of object is its length;
caller - The reference to causing function
prototype - Way for addition of properties of function
Rules of formation of names of variable
Should begin with the letter or underlining.
Should not contain blanks.
To be unique in the area of application.
There should not be more than 256 symbols.
The register of symbols in a name has meanings. Dev1 and DEV1 is different variable.
Should not coincide with names of the code of the designer, for it in this manual all variable begin with symbols DEV.
Before use variable it is not necessary to define.The following key word is applied to definition variable: var devx="12345";
Types of the data
In JAVASCRIPT exists the following types of the data:
string - sequence of symbols in inverted commas;
numbers - integers and decimal fractions;
boolean - True or False;
Null - data are not present;
object - the reference.
Special symbols
\n - new line;
\t - horizontal tabulation;
\f - new page;
\b - backspace;
\r - return of the carriage;
\ - to forbid reaction to the following symbol.
The operators of assignment of value
operator
example
mathematics
=
devx=devy
devx=devy
+=
devx+=devy
devx=devx+devy
-=
devx-=devy
devx=devx-devy
*=
devx*=devy
devx=devx*devy
/=
devx/=devy
devx=devx/devy
%=
devx%=devy
devx=devx%devy
The note: it is possible to use both record of an example, and usual mathematical record.
The operators of comparison
== - equal to;
!= - not equal to;
> - greater than;
>= - greater than or equal to;
< - less than;
<= - less than or equal to.
THE RECOMMENDATION: With an insert of the script - code in object HTML, in tag SCRIPT, do not use the operators of comparison < and >, in exchange use and < = and > =. It will allow an insert to work correctly.
The other operators
+ - addition;
- - subtraction;
* - multiplication;
/ - division;
% - the remainder after division;
++ - unary increment;
-- - unary decrement;
& or and - bitwise AND ;
|,or - bitwise OR;
^ or XOR - bitwise XOR;
<< - bitwise Left Shift;
>> - bitwise Right Shift;
>>> - unsigned Right Shift;
&& - logical AND ;
|| - logical OR;
! - logical NOT.
THE STRINGS OPERATORS:
+ - string concatenation;
Compares lines by comparison of codes of symbols beginning from left to right.
>;
>=;
<;
<=.
Comment
// text - the comment in one line.
/* text */ - the comment in some line.;
THE MANAGING OPERATORS
The operators of branching:
If;
If,,,Else;
Switch.
The operators of cycles:
for;
while.
The operators of branching
If;
If,,,Else;
Switch.
If if (condition) {operators};, If the condition has value "true" to execute "operators", if "false" nothing to do. The braces can be omitted, if inside them there is one operator. EXAMPLE 1 - to print the message by applying the operator in one line:
If,,,Else if (condition) {operators_1} else {operators_2}; , If the condition has value "true" the operators_1 are carried out, differently operators_2 are carried out. The braces can be omitted, if inside them there is one operator. EXAMPLE - variable to set value "true", if value true to give out the message "Expression is true", otherwise to give out the message "Expression is false":
Switch switch (expression) {case one or several expressions1 through a point: operators1; break; case one or several expressions2 through a point: operators2; break; case one or several expressions3 through a point: operators3; break; ... default: operators;}, The value "expression" is calculated. The value of this expression is consecutive is compared to each of value of expressions in each of lines case. The operators of a line "case" are carried out, in which first found out equality of values. If equality is not present in one line case, the operators of a line "default" are carried out. EXAMPLE:
The operators of cycles:
for;
while.
for for (devi=beginning; condition; change) { operators1 {if (condition1){break;} operators2 {if (condition2){continue;} operators3 },
To carry out "operators1"-"operators3", while "condition" has value "true", at the end of each cycle to change value of a variable cycle "devi" by a operators "change", if the condition has value "false ", the cycle can not be executed of any time. During performance of the operators the "condition1" is checked, if it true, performance of a cycle is finished by a operator "break". During performance of the operators the "condition2" is checked, if it true, is carried out transition by the beginning of a cycle by a operator "continue" and the performance "operators 3" does not occur. The operators "Change" should correct change value of a variable cycle "devi", if it not so will be organized an infinite cycle. When the script is carried out long, one of the possible reasons is the infinite cycle. If there was a suspicion on an infinite cycle, finish work by pressing ALT + CTRL + DEL, start the designer, analyse carried out cycles, insert additional debugging conditions of an exit from a cycle.
EXAMPLE 1 - to execute a cycle 3 times giving out the message with each performance:
EXAMPLE 2 - to charge a cycle on 3 performances, but with value of a variable cycle equal 2 to interrupt a cycle, to give out the message with each performance of a cycle:
EXAMPLE 3 - to execute a cycle 3 times giving out the message with each performance, except 2 performances:
while while (condition) {operators1 {if (condition1){break;} operators2 {if (condition2){continue;} operators3 } ,
To carry out " operators 1" - "operators 3 " while "condition" has value "true", if the "condition" has "false", the cycle can not be executed of any time. During performance of the operators the "condition1" is checked, if it true, performance of a cycle is finished by operator "break". During performance of the operators the condition 2 is checked, if it true, is carried out transition by the beginning of a cycle by the operator "continue" and the performance "operators 3" does not occur. The operators "Change" should correct change value of a variable cycle "devi", if it not so will be organized an infinite cycle. When the script is carried out long, one of the possible reasons is the infinite cycle. If there was a suspicion on an infinite cycle, finish work by pressing ALT + CTRL + DEL, start the designer, analyse carried out cycles, insert additional debugging conditions of an exit from a cycle.
EXAMPLE 1 - to execute a cycle 3 times giving out the message with each performance:
EXAMPLE 2 - to charge a cycle on 3 performances, but with value of a variable cycle equal 2 to interrupt a cycle, to give out the message with each performance of a cycle:
EXAMPLE 3 - to execute a cycle 3 times giving out the message with each performance, except 2 performances:
The built~in functions JAVA:
escape
eval
isNaN
parseFload
parseInt
typeof
escape escape() , Returns encodes String objects so they can be read on all computers.. EXAMPLE - to show the returned data with value of argument "a":
eval eval(expression) , Calculates expression and returns its value EXAMPLE - to show the sum " 1 + 2 + 3 + 4 "
isNaN isNaN(value) , Analyzes value and returns "true" if the value is not number. EXAMPLE - to show, that the string "abc" is not number:
parseFload parseFload("text") , Transforms "text" in to number from a floating point, if text not the number returns "NaN". EXAMPLE:
parseInt parseInt("text") , Transforms "text" to an integer, if "text" not the number returns "NaN". EXAMPLE:
typeof typeof() - Returns a type of object as a string. EXAMPLE - to show a type of object a constant "true":
THE BUILT~IN OBJECTS:
Object Array
Object Boolean
Object Date
Object Function
Object Math
Object Number
Object String
Object Array The object Array represents properties and methods of work with one-dimensional arays.
Creation of object Array:
devar=new Array() - Creation of array EXAMPLE - to show value of object:
devar=new Array(10) - Creation of array from 10 elements EXAMPLE - to show value of object:
devar=new Array("a","b","c") - Creation of array from 3 elements with assignment of values of elements. EXAMPLE - to show value of object:
Property of object Array length - Quantity of elements of an erray. EXAMPLE - to create array from 3 elements with values: 1,2,3; to increase dimension of array up to 10; to show array:
Methods of object Array:
join join([Symbol]) - Returns the string containing all elements of array splitted by point, if "Symbol" is not given, if is given, splitted by "Symbol". EXAMPLE - to show values of elements of array as a string splitted by a symbol "-":
reverse reverse() - Changes the order of an arrangement of elements of array on opposite. EXAMPLE - to change the order of an arrangement of elements of array on opposite and to show values of elements:
sort sort([Function]) - If the "Function" is not given to sort array by increase of value of elements of array. If the "Function" is given to sort array by increase of values returned by function. EXAMPLE - to sort by increase of values of elements of array and to show result:
EXAMPLE - array to sort by decrease of values of elements and to show result:
Object Boolean The object Boolean provides work with logic objects.
Creation of object Boolean:
devar=new Boolean() - Creation of object with value false;
devar=new Boolean(true) - Creation of object with value true.
Methods of object Boolean:
toString() - Returns value as one of strings: "true", "false". EXAMPLE - to show value of object as a string with value "false":
valueOf() - Returns value of object; EXAMPLE - to show value of object with value "true":
Object Date This object gives an opportunity to work with dates .
Creation of object Date:
devdata=new Date() - The object devdata is created, it has value of current date; EXAMPLE:
devdata=new Date(1000) - The object devdata is created, it has value of date later 1000 mlseconds from January 1, 1970 00:00:00; EXAMPLE:
devdata=new Date(2000,0,27) - The object devdata is created, it has value of date on January 27, 2000 00:00:00; EXAMPLE:
devdate=new Date("September 12,2000 01:00:12") - The object has value of date; EXAMPLE:
Methods of object Date:
getDate
getDay
getHours
getMinutes
getSeconds
getTime
getTimezoneOffset
getYear
parse
setDate
setHours
setMinutes
setSeconds
setTime
setYear
toGMTString
toLocaleString
UTC
getDate getDate() - Returns number of month as an integer. EXAMPLE - to give out number of month of current date.
getDay getDay() - Returns day of week as an integer. EXAMPLE - to give out day of week of current date.
getHours getHours() - Returns hours of current time as an integer. EXAMPLE - to give out hours of current time.
getMinutes getMinutes() - Returns minutes of current time as an integer. EXAMPLE - to give out minutes of current time:
getSeconds getSeconds() - Returns seconds of current time as an integer. EXAMPLE - to give out seconds of current time:
getTime getTime() - Returns as an integer quantity of miliseconds between January 1, 1970 at 00:00:00 on Greenwich and object Date. EXAMPLE - to give out miliseconds past with 1.01.1970 00:00:00 and moment of start of an example:
getTimezoneOffset getTimezoneOffset() - Returns as an integer a difference between local time and time on Greenwich in minutes. EXAMPLE - to give out a difference in minutes between local time and time on Greenwich:
getYear getYear() - Returns year as an integer. EXAMPLE - to give out by an integer current year:
parse parse(Date) - Returns as an integer quantity of miliseconds between January 1, 1970 at 00:00:00 on Greenwich and value of Date. To apply it was not possible.
setDate setDate(Integer) - Sets day of month by an integer in an interval from 1 up to 31. EXAMPLE - to set 10 numbers of current month to object "Date" and to show date:
setHours setHours(Integer) - Sets hours by an integer in an interval from 0 up to 23. EXAMPLE - to object Date to set value of curren date, and to change this value by set value of hours = 23 hours, to show the received value:
setMinutes setMinutes(Integer) - Sets minutes by an integer in an interval from 0 up to 59. EXAMPLE - object Date to set value of current date and time, and to change this value by set minutes value 3, to show the received value:
setSeconds setSeconds(Integer) - Sets seconds by an integer in an interval from 0 up to 59. EXAMPLE - object Date to set value of current date to change this value by setting value of seconds = 7, to show the received value:
setTime setTime(Integer) - Sets by an integer of miliseconds local date and time in relation to January 1, 1970 00:00:00 on Greenwich. EXAMPLE - to receive local: date, time for 1 second later on January 1, 1970 00:00:00 on Greenwich:
setYear setYear(Integer) - To set year by an integer in an interval from 1900. EXAMPLE - to change current date, by setting 2000, to show result:
toGMTString toGMTString() - Transforms the data of local time of object Date to time on Greenwich and returns as a string. EXAMPLE - to show local time on Greenwich:
toLocaleString toLocaleString() - Transforms time on Greenwich to local time and returns as a string. EXAMPLE - to give out by an integer last two figures of current year:
UTC UTC(year, month, day [, hour] [, minutes] [, seconds])- Returns quantity of miliseconds between January 1, 1970 at 00:00:00 on Greenwich and value of object Date as an integer. To apply it was not possible.
Object Function The object is intended for creation and compilation of functions in language JAVASCRIPT.
Creation of object Function:
devf=new Function("x1","x2","code") EXAMPLE: to create function in this format and to call it :
function devf(x1,x2...) { operators1; return expression1; operators2; return expression2;} EXAMPLE: to create function in this format and to call it :
Properties of object Function:
arguments - The reference to array Arguments containing arguments of function. EXAMPLE - to create new object Function with arguments, to call function and to show values of Arguments:
caller - Defines function, which calls function. EXAMPLE - to create new object Function to call function and to show value of property caller:
prototype - The reference to object, determining a way of addition of properties to the object Function. EXAMPLE - to create new object Function to call function and to show value of property prototype:
Object Arguments of object Function:
length - Returns an integer quantity of arguments, necessary function. To apply it was not possible.
Object Math Represents a set of properties and methods for work with mathematical constants and functions. For access to properties and methods it is necessary before them, through a point to specify the reference object as: Math.property, method EXAMPLE - to show value of PI:
Properties of object Math:
E Math.E - Returns the constant e is Euler''s constant, approximately equal to 2.178;
LN10 Math.LN10 - Returns the natural logarithm of 10. The LN10 property is approximately equal to 2.302.
LN2 Math.LN2 - Returns the natural logarithm of 2. The LN2 property is approximately equal to 0.693;
LOG10E Math.LOG10E - Returns the base-10 logarithm of e, Euler''s constant. The LOG10E property, a constant, is approximately equal to 0.434;
LOG2E Math.LOG2E - Returns the base-2 logarithm of e, Euler''s constant. The LOG2E property, a constant, is approximately equal to 1.442;
PI Math.PI - Returns the ratio of the circumference of a circle to its diameter, approximately 3.141592653589793;
SQORT1_2 Math.SQORT1_2 - Returns the square root of 0.5, or one divided by the square root of 2. The SQRT1_2 property, a constant, is approximately equal to 0.707;
SQRT2 Math.SQRT2 - Returns the square root of 2.The SQRT2 property, a constant, is approximately equal to 1.414.
Methods of object Math:
abs
acos
asin
atan
atan2
ceil
cos
exp
floor
log
max
min
random
round
sin
sqrt
tan
abs Math.abs(x) - Returns the absolute value of a numeric expression x;
acos Math.acos(x) - Returns the arccosine of a numeric expression x;
asin Math.asin(x) - Returns the arcsine of a numeric expression x;
atan Math.atan(x) - Returns the arctangent of a numeric expression x;
atan2 Math.atan2(y,x) - Returns the angle (in radians) from the X axis to a point (y,x). Where: x it a numeric expression representing the cartesian x-coordinate, y it a numeric expression representing the cartesian y-coordinate;
ceil Math.ceil(x) - Returns the smallest integer greater than or equal to its numeric a numeric expression x;
cos Math.cos(x) - Returns the cosine of a numerical expression X;
exp Math.exp(x) - Returns e (the base of natural logarithms) raised to a power x. The required x argument is numeric expression representing the power of e. The return value is enumber. The constant e is Euler''s constant, approximately equal to 2.178 and number is the supplied argument;
floor Math.floor(x) - Returns the greatest integer less than or equal to its numeric expression x;
log Math.log(x) - Returns the natural logarithm (the base is e) of a numeric expression x;
max Math.max(x1, x2, ...) - Returns maximal of numerical values of expressions x1, x2...;
min Math.min(x1, x2,...) - Returns minimal of numerical values of expressions x1, x2...;
pow Math.pow(x1, x2) - Returns the value of a x expression taken to a specified power x2, x1 and x2 numerical expressions;
random Math.random() - Returns a pseudorandom number in an interval from 0 up to 1;
round Math.round(x) - Returns a supplied numeric expression rounded to the nearest integer.;
sin Math.sin(x) - Returns a sine of numeric expression x;
sqrt Math.sqrt(x) - Returns a square root numeric expression x;
tan Math.tan(x) - Returns tangent of numeric expression x.
Object Number Represents a set of properties and methods for work with numbers.
Creation of a copy of object. devnum=123; or devnum=new Number(123);
Properties of object Number:
MAX_VALUE - The maximal number in JAVASCRIPT (~1,79E+308) EXAMPLE:
MIN_VALUE - The minimal number in JAVASCRIPT (~2,22E-308) EXAMPLE:
NaN - Value, which not number; EXAMPLE:
NEGATIVE_INFINITY - Negative infinity EXAMPLE:
POSITIVE_INFINITY - Positive infinity. EXAMPLE:
Methods of object Number:
toString([basis]) - Transforms numerical value to 10 system, if "basis" is omitted, or, if is specified in system of calculation determined by value "basis". EXAMPLE - to transform number 123 to binary system and to show result:
valueOf() - Returns binary value of property. To apply it was not possible.
Object String Represents property and methods for work with the text.
Creation of object String: devstring=new String(It is a string) or devstring="It is a string"
Properties of object String:
length - integer of quantity of symbols in a string. EXAMPLE - to show the size of a line "abc":
Methods of object String:
anchor
big
blink
bold
charAt
fixed
fontcolor
fontsize
indexOf
italics
lastIndexOf
link
small
split
strike
sub
substr
sup
toLowerCase
toUpperCase
anchor anchor("name") - Returns a string inserted inside of the text of a tag "A", with attribute NAME = "name". EXAMPLE - to insert the text into the tag "A" and to show result:
big big() - Returns a string inserted inside of the text of a tag "BIG". EXAMPLE - to insert the text in tag "BIG" and to show result:
blink blink() - Returns a string inserted inside of the text of a tag "BLINK". EXAMPLE - to insert the text in tag "BLINK" and to show result:
bold bold() - Returns a string inserted inside of the text of a tag "B". EXAMPLE - to insert the text in tag "B" and to show result:
charAt charAt(position) - Returns a symbol, which is in "position" of a line of object String. EXAMPLE - to show what symbol is in the first position of a line "1234567890":
fixed fixed() - Returns a string inserted inside of the text of a tag "TT". EXAMPLE - to insert the text in tag "TT" and to show result:
fontcolor fontcolor("color") -Returns a string inserted inside of the text of a tag "FONT", with attribute COLOR = "color". EXAMPLE - to insert the text in tag "FONT" and to set COLOR = "red", to show result:
fontsize fontsize("size") - Returns a string inserted inside of the text of a tag "FONT", with attribute SIZE = "size". EXAMPLE - to insert the text in tag "FONT" and to set SIZE =24, to show result:
indexOf indexOf(String_1[,position])- Returns a position of the first occurrence "String_1", since a "position" of object "String". EXAMPLE - to find and to show a position of the first occurrence "3" from 5 positions:
italics italics() - Returns a string inserted inside of the text of a tag "I". EXAMPLE - to insert the text in tag "I" and to show result:
lastIndexOf lastIndexOf(str[,position])- Returns a position of the first occurrence "str", since a "position " of object "String" in the opposite order of an arrangement of symbols. EXAMPLE - to find and to show a position first from the end of occurrence "3" from 5 positions from the end of a text "1234512345":
link link("href") - Returns a string inserted inside of the text of a tag "LINK", with attribute HREF = "href". EXAMPLE - to insert the text in tag "LINK" and to show result:
small small() - Returns a string inserted inside of the text of a tag "SMALL". EXAMPLE - to insert the text in tag "SMALL" and to show result:
split split(symbol) - Returns array of strings, created by splitting of value of the object "String" on a strings on a symbol "symbol". EXAMPLE - from a string "1/2/3/4/5/6/7/8/9/0" to receive a string with replacement of a symbol "/" on a symbol by default of a method "join" of object "Array":
strike strike() - Returns a string inserted inside of the text of a tag "STRIKE". EXAMPLE - to insert the text in tag "STRIKE" and to show result:
sub sub() - Returns a string inserted inside of the text of a tag "SUB". EXAMPLE - to insert the text in tag "SUB" and to show result:
substr substr(number, quantity) - Returns a part of a line, which is value of object String, number of symbols "quantity" and beginning by a symbol in a position "number". EXAMPLE - to show by this method first three symbols of a string "1234567890":
sup sup() - Returns a string inserted inside of the text of a tag "SUP". EXAMPLE - to insert the text in tag "SUP" and to show result:
toLowerCase toLowerCase() - Transforms symbols of value of object String in lower case. EXAMPLE - to transform a string "ABC" to a string lower case and to show result:
toUpperCase toUpperCase() - Transforms symbols of value of object String in upper case. EXAMPLE - to transform a string "abc" to a string upper case and to show result:
The forbidden words It is impossible to use the following words, which for the name of functions, methods, variable or objects:
abstract
boolean
breack
byte
case
catch
char
class
const
continue
default
delete
do
double
else
extends
false
final
finally
float
for
function
goto
if
implements
import
in
instanceof
int
interface
long
native
new
null
package
private
protected
public
reset
return
short
static
super
switch
synchronized
this
throw
throws
transient
true
try
typeof
var
void
while
with
INPUT~OUTPUT
Window of the message
Window of confirmation
Window of input
Window of the message alert("text"); Opens a window with the message "text" and button "OK", click which on finishes viewing of the message. EXAMPLE - to give out the message:
Window of confirmation Confirm("text"); Opens a window with the message "text" and buttons: "OK", "Cancel". Returns "true", if will click the button "OK" and "false", if "Cancel". EXAMPLE - to give out a window of confirmation and to show the returned data:
Window of input Prompt("text","by default"); Returns the entered data, if the input is completed by click of the button "OK", or pressing "Enter", or "null", if has clicked the button "Cancel". Shows "text" as the brief instruction on input. Shows " by default " in a field of input. EXAMPLE - to give out a window of input and to show the returned data: