LimeReport icon indicating copy to clipboard operation
LimeReport copied to clipboard

Doc: Please document Script Browser

Open pasnox opened this issue 6 years ago • 13 comments

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 :/

pasnox avatar Apr 25 '18 10:04 pasnox

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?

fralx avatar Apr 25 '18 20:04 fralx

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 .

pasnox avatar Apr 25 '18 21:04 pasnox

Here is a sample [test_js.zip] (https://github.com/fralx/LimeReport/files/1951010/test_js.zip)

fralx avatar Apr 26 '18 12:04 fralx

What is the language do we use on script manager? javascript?

yanis60 avatar Apr 29 '18 19:04 yanis60

Javascript

fralx avatar May 02 '18 06:05 fralx

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 avatar May 04 '18 17:05 sg-james

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?

fralx avatar May 07 '18 07:05 fralx

Windows 10 Qt 5.5.1 msvc12 (2013) CONFIG+=no_zint

The text renders "ReferenceError: testString is not defined"

sg-james avatar May 07 '18 13:05 sg-james

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

fralx avatar May 07 '18 14:05 fralx

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 ^

pasnox avatar Jun 14 '18 13:06 pasnox

Hi

Any way i can use registered variable inside this scope ?

Use getVariable(VariableName) function :)

fralx avatar Jun 15 '18 11:06 fralx

Ah thanks, I will test hat. Worth a documentation update ;)

pasnox avatar Jun 15 '18 12:06 pasnox

The documentation is my pain :) as an English :)

fralx avatar Jun 15 '18 12:06 fralx