LimeReport
LimeReport copied to clipboard
Doc: Please document Script Browser
I did not success to create new functions in this UI, nor in the Script tab in the workspace. How can i create my own js fucntion ? I tried something like this in the Script tab without success (give parse error):
function theName() { return 42; }
EDIT: Looking at the code make it clear the UI for functions is not implemented, they are even not serialized as they are not part of the ScriptContext object. Also, the code suggest Script tab is an init script to call early, not a palce to create functions etc. This gimme the only option to create the fucntion from c++, somehtin i would like to avoid :/
Hi! I have created function as you described in the init script without any problem. (no pass error is happend) And this function i can use in TextItem's script as $S{theName();}. May be I not clear undestand how do you want create and use the function?
Can you paste me the complete init script to put in the script tab so I can test as well?
On Wed, Apr 25, 2018, 22:45 fralx [email protected] wrote:
Hi! I have created function as you described in the init script without any problem. (no pass error is happend) And this function i can use in TextItem's script as $S{theName();}. May be I not clear undestand how do you want create and use the function?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fralx/LimeReport/issues/105#issuecomment-384428107, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0YWWOdIT5SH4xlY1W0CrjiRyBiWy8Cks5tsOBhgaJpZM4TjM4o .
Here is a sample [test_js.zip] (https://github.com/fralx/LimeReport/files/1951010/test_js.zip)
What is the language do we use on script manager? javascript?
Javascript
The test_js.lrxml does not work with the latest develop branch ee94506 , but does with release tag1.4.79 8fd072c. Is that intended?
sg-james No, it's really strange. I checked and test_js works for me on both branches. What OS and Qt version do you use?
Windows 10 Qt 5.5.1 msvc12 (2013) CONFIG+=no_zint
The text renders "ReferenceError: testString is not defined"
I've checked. Really on version Qt 5.5.1 in the develop branch the error has present. On version 5.6.2 all works good. If you need to build limereport on version 5.5 you have to use CONFIG+=qtscriptengine. With this option limereport will be build with old qt script engine that was deprecated in new Qt versions. I'll fix the make file soon
Hi back, so indeed, all works fine. I had few problems:
- sql query returned 0 rows
- usage of variables inside the js code
I fixed the first, but it seems second is not fixable (supported). Any way i can use registered variable inside this scope ?
Here is a snippet from it:
function prettyFloat(value, precision) { var p = precision === undefined ? $V{DECIMALS_COUNT} : precision; return numberFormat(value, 'f', p); }
@fralx ^
Hi
Any way i can use registered variable inside this scope ?
Use getVariable(VariableName) function :)
Ah thanks, I will test hat. Worth a documentation update ;)
The documentation is my pain :) as an English :)