Skip to main content

JavaFX Script Programming Language

1 reply [Last post]
richardjome
Offline
Joined: 2010-02-04

The previous lesson walked you through setting up a development environment; here we will take a closer look at the Calculator.fx source code. The code in red below declares the program's script variables. Script variables are declared using the var or def keywords. The difference between the two is that var variables may be assigned new values throughout the life of the script, whereas def1 variables remain constant at their first assigned value. Here we have assigned some values to numOne and numTwo, but have left result uninitialized because this variable will hold the result of our future calculations:

def numOne = 100;
def numTwo = 2;
var result;

add();
subtract();
multiply();
divide();

function add() {
result = numOne + numTwo;
println("{numOne} + {numTwo} = {result}");
}

function subtract() {
result = numOne - numTwo;
println("{numOne} - {numTwo} = {result}");
}

function multiply() {
result = numOne * numTwo;
println("{numOne} * {numTwo} = {result}");
}

function divide() {
result = numOne / numTwo;
println("{numOne} / {numTwo} = {result}");
}

===================
baby name gift
special baby gifts

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
drivinginstructors
Offline
Joined: 2010-03-03

Thanks your JavaFX Script Programming Language . but i think some little error in your code. deeply check it .

Thanks
======================
[url=http://www.driving-instructors-birmingham.co.uk]driving lessons in Birmingham[/url]
[url=http://www.driving-instructors-birmingham.co.uk]driving schools in Birmingham[/url]
[url=http://www.driving-instructors-birmingham.co.uk]intensive driving courses in Birmingham[/url]