A simple Console Window for testing

4.96K viewsScripting
0

The scripting engine allows you to create alert() messages. These messages are pop-up windows and the last one is on top of all others. The other option is to use the JOptionPane.showMessageDialog() window but then the execution of the script is stopped each time when this method is called and you have to click each time to continue.

Both approaches are fine and useful. But I wanted to be able to constantly write messages into a text box with line numbering and without being interupted by pop-up messages. Further, I need the functionality which allows to copy the data in this text window to use it elsewhere. That’s the reason why I developed this simple Qconsole. It is far from perfect and has to be considered as a draft but good enough for you to play with and to improve it.

The attached zip file contains these files:
[list:20j1m7vb]
[*:20j1m7vb]Console Example.model[/*:m:20j1m7vb]
[*:20j1m7vb]qconsole.jar[/*:m:20j1m7vb]
[*:20j1m7vb]The Eclipse project “Quantrix Console”[/*:m:20j1m7vb][/list:u:20j1m7vb]

Next steps:
[list=1:20j1m7vb]
[*:20j1m7vb] Unzip the zip file[/*:m:20j1m7vb]
[*:20j1m7vb] Copy the qconsole.jar file into the ScriptingLibs folder of your Quantrix 4 installation. If the ScriptingLibs folder does not exist create it first.[/*:m:20j1m7vb]
[*:20j1m7vb] Open the model “Console Example.model”[/*:m:20j1m7vb]
[*:20j1m7vb] There are two Action scripts in this model: One starts the console directly from within Quantrix by using Groovy code (“Use Console”). The other one starts the console by importing the previously installed “qconsole.jar” file (“Use Console via JAR”)[/*:m:20j1m7vb]
[*:20j1m7vb] You can select the text in the qconsole window and copy with Ctrl + C and paste at another place[/*:m:20j1m7vb]
[*:20j1m7vb] Use the Scripting Console. Paste the sample code provided in the model: Click on “Matrix1” in the model browser and copy the code in its notes window below into the Scripting Console. Hit Crtl + Enter to run it. When you continue to add qc.add() statements be sure to delete the previous ones because otherwise the same data is added again and again when you hit Ctrl+Enter[/*:m:20j1m7vb][/list:o:20j1m7vb]

Important to know:
[list:20j1m7vb]
[*:20j1m7vb]The Groovy version creates a new window each time you start the action “Use Console”[/*:m:20j1m7vb]
[*:20j1m7vb]The version importing the qconsole.jar creates one window only and continuously adds your qc.add(“something”) statements to the window. This is very useful when testing by using the Scripting Console. BUT: You can’t create a new qconsole window when you close it because I have implemented it as a singleton object. This means that only one window can be opened as long the model is open. When you close the qconsole window and want to start a new one you have to close and re-open the model first.[/*:m:20j1m7vb][/list:u:20j1m7vb]

I know this is not perfect but a starting point. You are invited to improve this project and provide ideas and hints to make it more user friendly. Have fun!

Many thanks.

Dominik

0

Luca,
I fully agree with you. We should have an Output view in Quantrix which can be docked like the Scricpting console. The more I use scripting in Quantrix the more I am missing the debugging features. But there is hope: v4.1 will have the Qscript files back again and then the output window will maybe be back again.

Please feel free to make suggestions or changes to my simple console project. It’s not perfect yet and I haven’t had time to improve it so far.

Dominik

You are viewing 1 out of 4 answers, click here to view all answers.