| Tutorial | Classes | Functions | QSA Developer | Language | Library | Qt API Qt Script for Applications

[Prev: function] [Home] [Next: Control Statements]

var

var variableName;
var anotherVariableName = InitialValue;
var yetAnotherVariableName : typeName = InitialValue;

This keyword is used to declare and optionally initialize variables. If just the variableName is given, the variable is created, but it has no value, i.e. its value is undefined. If an InitialValue is given, the variable is created and assigned this InitialValue. Variables declared within functions are local to the function in which they are declared. Variables declared outside of functions and classes are global.

Variables may be given a typeName, in which case they should only be used to store objects of the given type.

Example:

    var i;
    var count = 22;
    var str = "string";
    var num : Integer = 38;
    var name : String = "Constantine";

[Prev: function] [Home] [Next: Control Statements]


Copyright © 2001-2002 TrolltechTrademarks
QSA version 1.0.0-beta1