2c. Characteristics of the QSA language: Language summary

Category Keywords

note autumn 2007

Trolltech slightly modified the language, the current version is 1.2.2, which is also in BrainVoyager 1.9. The fields below refer to the previous versions of Qt Script. The description of the language version 1.2.2. by Trolltech can be found here. One change is that arrays can now also be used as associative arrays (kind of "hash maps"). There are now regular expressions (RegExp) and the string functions are being described.

Because the changes are mainly extensions instead of changes, the previous descriptions of Qt Script are (temporarily) still listed below.

Array handling

Array
push()
unshift()
splice()
concat()
join()
toString()
reverse()
sort

Assignment operators Change variable (=), Add to variable (+=), Subtract from variable (-=), Multiplies with variable (*=),
Divides by variable (/=)
,
Bit-wise AND (&=)
, Bit-wise XOR (^=), Bit-wise OR (|=),
Bit-wise left shift in bits (<<=)
,
Bit-wise sign-preserving right shift in bits (>>=),
Bit-wise zero-padding right shift in bits (>>=)
Comments //  for single line comments
/*...*/
 for multiple line comments
Constants/Built-in variables Infinity, NaN, undefined, arguments, Application.argv[i]
Control statements break, case, catch, continue, default, do, else, for, if, finally, label, return, switch, throw, try, while, with
Dates/Times Date, getDay(), getFullYear(), getHours(), getMilliseconds(), getMinutes(), getMonth(), getSeconds(), getTime(), getTimeZoneOffset()
Universal Coordinated Time (=Greenwich Mean Time, GMT)
getUTCDate()
, getUTCDay(), getUTCFullYear(), getUTCHours(), getUTCMilliseconds(), getUTCMinutes(), getUTCMonth(), getUTCSeconds(), getUTC()
Set functions
setDate()
, setFullYear(), setHours(), setMilliseconds(), setMinutes(), setMonth(), setSeconds(), setTime(), setUTCDate(), setUTCFullYear(), setUTCHours(), setUTCMilliseconds(), setUTCMinutes(), setUTCMonth(), setUTCSeconds(), setUTCTime()
parse()
, toString(), toLocaleString(), toUTCString
Number toExponential( optDecimals ), toFixed( optDecimals ), toPrecision( optSignificanDigits ), toString()
Declarations var, const, class, this, function
Error Handling try...catch, Built-in Exceptions
Graphical components and user input MessageBox
TimedMessageBox

Dialog
: exec(), newTab(), newColumn(), addSpace( nrOfSpaces ), add( component )
CheckBox
, ComboBox, GroupBox, LineEdit, NumberEdit, RadioButton, SpinBox, TextEdit TimeEdit, DateEdit Input: getText(), getNumber, getItem(), caption
FileDialog
: getOpenFileName( filter: String ), getSaveFileName( filter: String ), getExistingDirectory( dir: String ), getOpenFileNames( dir: String, filter: String )
Math abs(), cos(), acos(), sin(), asin(), atan(), atan2(), tan(), ceil(), floor(), round(), exp(), log(), max(), min(), pow(), sqrt(), random(), round()
Objects Math, Qt, System
Data types String, Boolean, ByteArray, Color, Date, Font, Function (at runtime), Number, Object, PixMap, Point, Rect
RegExp
, Size, Dir, File
Operators Arithmetic
Addition (+)
, Pre/post-increment (++), Subtraction (-)
Pre/post-decrement (--)
, Modulus arithmetic (%)
Multiplication (*)
, Division (/)
String concatenation (+) and (+=)

Comparison
Equality (==)
, Equality of value and type (===), Inequality (!=)
Inequality of value or type (!==)

Less Than (<=)
, Less Than or Equal To (<=)
Greater Than (>)

Greater Than or Equal To (>=)

Logical
Is
, And (&&), Or (||), Negation (!)

Bitwise
Xor (^)
, And (&), Or (|), Not (~), Bitwise left shift (<<) Bitwise sign propagating right shift (>>) Bitwise zero-operand right shift (>>>)

Special
?: (expression ? resultIfTrue : resultIfFalse)
, (evaluation of 1st and 2nd operand, returns 2nd)
function (var variable = function( optArgs ) { Statements } )
in (property in Object, returns boolean)
instanceof (object instanceof type, returns boolean)
new (var instance = new Type( optArgs )
this (this.property)
typeof (typeof item)

Built-in functions connect( signallingObj, signal, receivingObj, slot )
debug( expression )

eval( string )
, isFinite( expression ), isNaN( expression ), startTimer( interval, timeoutFunction )
killTimer( timerId )
, killTimers(), parseFloat( string ), parseInt( string, optBase )

System
getenv()
setenv( environmentVar, value )
unsetenv( environmentVar )
print( expression )
println( expression )

Script Engine AboutQt

String functions

charAt(), charCodeAt(), endsWith(), find(), findRev(), fromCharCode(), indexOf(), isEmpty(),
lastIndexOf(), toLowerCase(), toUpperCase(), substring(), substr(), startsWith(), split(),
right(), left(), mid(), replace(), match(), lower(), upper(), toString(), valueOf(), length

Filesystem

File

open( accessMode : Number ), close(), remove(), readByte(), read(), readLine(), readLines(), writeByte( byte : Number ),

write( data : String, length : Number ), writeLine( data : String )

 

Directory

filePath( fileName : String ), absFilePath( fileName : String ), cd( dirName : String ), cdUp(),

entryList( filter : String, filterSpec : Number, sortSpec : Number ) , mkdir( dirName : String ), mkdir(),

mkdirs( dirName : String ), mkdirs(), rmdir( dirName : String ), rmdir(), rmdirs( dirName : String ), rmdirs(),

fileExists( fileName : String ), setCurrent()

 

Process

start( env : String[] ), launch( stdin : String, env : String[] ), readStdout(), readSterr(), canReadLineStdout(),

canReadLineStderr(), readLineStdout(), readLineStderr(), tryTerminate(), kill(), writeToStdin( buffer : String ), closeStdin()

Regular expressions

RegExp( )

Next: 2d. Characteristics of the QSA language: Getting started with QSA
Index