Page 1 of 1

Javascript question function call from another .js file

Posted: Mon May 20, 2019 9:18 am
by yogi108
Hi,

I have some Javascript files, which are working well.
Creating buttons in the tool register of the PDF-XChange Editor,
after clicking the buttons the action desired runs like a charm.

Now I came across the following:
I press one button and at the end of the script I have a yes/no dialog.
If yes it should call a function from another Javascript file, not inside the same file.

The separate file with only one function in it works if called through the button I created.
The file name and the function name are
filename "dblpagenumbers.js"
function "function dblpagenumbers()"
No parameters to pass.

if I call in the script the function from the other script
dblpagenumbers();
I get the error at the last line of the script:
Mozilla JavaScript Engine is initialized (vJavaScript-C 17.0.4esrpre)
App:Init:204: TypeError: this.flattenPages is not a function
but all other actions are also not working in this separate script.

So again the scripts are working well if called separately from the menubuttons.

Is there any hint/syntax to call a function from the same directory
from another script?
As I understand the scripts are loaded all from this PDF-XChange Javascript directory at starting of PDF-XChange.

Simple thing long explained, hope you understand,

regards,
Fritz

Re: Javascript question function call from another .js file

Posted: Mon May 20, 2019 11:15 am
by Tracker Supp-Stefan
Hello Fritz,

I've asked a colleague from the dev team for some help with your enquiry and we will post further guidance shortly!

Regards,
Stefan

Re: Javascript question function call from another .js file

Posted: Mon May 20, 2019 11:42 am
by yogi108
Thanks in advance,

regards
Fritz

Re: Javascript question function call from another .js file

Posted: Wed May 22, 2019 8:24 pm
by TrackerSupp-Daniel
:)

Re: Javascript question function call from another .js file  SOLVED

Posted: Tue Jul 23, 2019 8:12 am
by yogi108
Tracker Supp-Stefan wrote:
Mon May 20, 2019 11:15 am
Hello Fritz,

I've asked a colleague from the dev team for some help with your enquiry and we will post further guidance shortly!

Regards,
Stefan
Hi there,

As of now there was no answer, so to whom it concerns I did the following with success:

Copying the function from the separate file and renaming it,
passing the reference of the PDF to be worked on to the function
and renamed all "this." to "Mydoc." (MyDoc is the variable which holds the reference to the PDF)

Now it works.

It seems that a call from the button delivers the "this" as reference to the active document, if
called from another file "this" is maybe undefined...

Have a nice time,
Fritz

Re: Javascript question function call from another .js file

Posted: Tue Jul 23, 2019 9:19 am
by Will - Tracker Supp
Hi Fritz,

Sorry for the lack of response, but glad you got this working and thanks for the tip! :)

Cheers,