Skip to main content
Known Participant
April 6, 2016
Answered

Sequence to update the script of one function

  • April 6, 2016
  • 2 replies
  • 934 views

Hi all

I discovered the very effective batch sequences to deal with many files.

This time I would like to update only one function of my script (that includes many other functions).

So far , I haven't found how to do that with a sequence.

I would appreciate any help.

Thanks in advance

Michel

This topic has been closed for replies.
Correct answer try67

No. It's:

this.addScript("ScriptName", "ScriptCode");

2 replies

Inspiring
April 6, 2016

There is a trick you can use, but I don't really recommend it unless you're desperate. Document-level JavaScripts are loaded by alphabetical order when the document is opened, so if you add a new document-level JavaScript that has a name that would load after the one that contains the function you want to remove, you can use the doc.addScript method to add a function that has the same name. The one that is loaded last will be the one that's used when it's subsequently called. The problem is you can't count on this alphabetical loading, though it's always been that way with Acrobat/Reader since JavaScript was introduced in version 3.

hmn44Author
Known Participant
April 6, 2016

interresting ! I didn't know how it works.

By the way do you know why empty lines lines are added to my scripts ?

try67
Community Expert
Community Expert
April 6, 2016

You can't update a specific function. You can set the entire code to the new value, though.

hmn44Author
Known Participant
April 6, 2016

That's what I was scare of  ! so what's the way to do it ? is it this.script = a string containing the new entire script ?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 6, 2016

No. It's:

this.addScript("ScriptName", "ScriptCode");