Javascript question function call from another .js file  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Post Reply
User avatar
yogi108
User
Posts: 71
Joined: Thu Mar 09, 2017 9:13 am
Location: Austria, Theiß
Contact:

Javascript question function call from another .js file

Post by yogi108 » Mon May 20, 2019 9:18 am

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
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13561
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Javascript question function call from another .js file

Post by Tracker Supp-Stefan » 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

User avatar
yogi108
User
Posts: 71
Joined: Thu Mar 09, 2017 9:13 am
Location: Austria, Theiß
Contact:

Re: Javascript question function call from another .js file

Post by yogi108 » Mon May 20, 2019 11:42 am

Thanks in advance,

regards
Fritz
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

User avatar
TrackerSupp-Daniel
Site Admin
Posts: 2526
Joined: Wed Jan 03, 2018 6:52 pm

Re: Javascript question function call from another .js file

Post by TrackerSupp-Daniel » Wed May 22, 2019 8:24 pm

:)
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

User avatar
yogi108
User
Posts: 71
Joined: Thu Mar 09, 2017 9:13 am
Location: Austria, Theiß
Contact:

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

Post by yogi108 » Tue Jul 23, 2019 8:12 am

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
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

User avatar
Will - Tracker Supp
Site Admin
Posts: 6806
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Javascript question function call from another .js file

Post by Will - Tracker Supp » Tue Jul 23, 2019 9:19 am

Hi Fritz,

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

Cheers,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com

Post Reply