QtScript: Difference between revisions
(Created page with "LabRPS supports ECMAScript like dynamic scripting language, as defined in standard [http://www.ecma-international.org/publications/standards/Ecma-262.htm ECMA-262]. Microsoft's JScript, and Netscape's JavaScript are also based on the ECMAScript standard. For an overview of ECMAScript, see the [http://doc.qt.io/qt-5/ecmascript.html ECMAScript reference]. If you are not familiar with the ECMAScript language, there are several existing tutorials and books that cover this su...") |
No edit summary |
||
Line 1: | Line 1: | ||
{{TOCright}} | |||
LabRPS supports ECMAScript like dynamic scripting language, as defined in standard [http://www.ecma-international.org/publications/standards/Ecma-262.htm ECMA-262]. Microsoft's JScript, and Netscape's JavaScript are also based on the ECMAScript standard. For an overview of ECMAScript, see the [http://doc.qt.io/qt-5/ecmascript.html ECMAScript reference]. If you are not familiar with the ECMAScript language, there are several existing tutorials and books that cover this subject, such as [http://shop.oreilly.com/product/9780596805531.do JavaScript: The Definitive Guide]. | LabRPS supports ECMAScript like dynamic scripting language, as defined in standard [http://www.ecma-international.org/publications/standards/Ecma-262.htm ECMA-262]. Microsoft's JScript, and Netscape's JavaScript are also based on the ECMAScript standard. For an overview of ECMAScript, see the [http://doc.qt.io/qt-5/ecmascript.html ECMAScript reference]. If you are not familiar with the ECMAScript language, there are several existing tutorials and books that cover this subject, such as [http://shop.oreilly.com/product/9780596805531.do JavaScript: The Definitive Guide]. | ||
Latest revision as of 23:25, 9 August 2022
LabRPS supports ECMAScript like dynamic scripting language, as defined in standard ECMA-262. Microsoft's JScript, and Netscape's JavaScript are also based on the ECMAScript standard. For an overview of ECMAScript, see the ECMAScript reference. If you are not familiar with the ECMAScript language, there are several existing tutorials and books that cover this subject, such as JavaScript: The Definitive Guide.
Console Functions (not part of ECMAScript)
attachDebugger(bool)
The debugger enables the application user to inspect the state of the script environment and control script execution. you can enable debugging mode at any point by issuing attachDebugger(true) and return to the normal running mode by issuing attachDebugger(false).
clear()
Clears the complete contents of the scripting console and leave only a user prompt.
collectGarbage()
The garbage collector will attempt to reclaim memory by locating and disposing of objects that are no longer reachable in the script environment. Normally you don't need to call this function; the garbage collector will automatically be invoked when the LabRPS decides that it's wise to do so. It is recommended to run this manually when you are done with large data objects.
print(argument1, argument2, ...)
prints the arguments to the console as formatted in the function. Note: if the console is in debugger mode all the print function output will be redirected to debugger console
Using with Table and Matrix
Scripting capability is mainly intended for Table/Matrix data manipulation. You can access the main LabRPS Application window as rps object inside QtScript.
// Get pointer to Table with name "Table1" and stores it to the object variable tab tab = rps.getTableHandle("Table1") // get tab row count tab.rowCount() // get tab column count tab.colCount() // set tab row count to 50 tab.setRowCount(50) // set tab column count to 5 tab.setColCount(5) // get tab value at row 1, column 1 position inside the table to variable val and print the value val = tab.getCell(1, 1) print(val) // set tab value at row 1, column 1 position inside the table to 0.897 tab.setCell(1, 1, 0.897)
//Apply a muparser function "col(1)^2" to generate 2nd column values of table tab tab.applyFunction(2, "col(1)^2")
// Get pointer to Matix with name "Matrix1" and stores it to the object variable mat mat = rps.getMatrixHandle("Matrix1")