Javascript question function call from another .js file  SOLVED

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

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

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

Javascript question function call from another .js file

Post 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
"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: 17824
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 »

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: 74
Joined: Thu Mar 09, 2017 9:13 am
Location: Austria, Theiß
Contact:

Re: Javascript question function call from another .js file

Post by yogi108 »

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: 8436
Joined: Wed Jan 03, 2018 6:52 pm

Re: Javascript question function call from another .js file

Post by TrackerSupp-Daniel »

:)
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
yogi108
User
Posts: 74
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 »

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: 6815
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 »

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