Skip to main content
Inspiring
December 6, 2019
Question

Basically Identical Scripts but Part of One Won't Work

  • December 6, 2019
  • 2 replies
  • 872 views

Hi again, everyone.

 

So, I've got two folder level scripts that are practically identical. The only difference is that one is meant to merely save the current PDF Form open to specific folder based on field data, the other is meant to batch import from a tab deliminated file and save it based on the same criteria. 

 

PasteBin of Save Script - https://pastebin.com/NdWSzKxL

PasteBin of Import Script - https://pastebin.com/Wv0JG52p

 

The import script is the one not working, but only part of it isn't. The import is done with a while loop with a switch block inside of it. The first 4 cases in the switch are run if the last character of the string is a non-number (with NaN) and the -1 case is run if the string ends in a number.

 

It runs the imports of the first four cases with ease, but for some reason it breaks if it's all numbers. Whereas my Save script runs everything just fine. The code was literally copy-pasted from the Save to the Import but for some reason it's breaking when inside the While loop.

 

Any ideas?

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
December 6, 2019

So first, just because one script works doesn't say anything about a script you've modified so drastically. We'd need to see the script say anything about it, as well as know what if any error messages are being reported. Can you please post the text for the script. 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Bernd Alheit
Community Expert
Community Expert
December 7, 2019

The scripts are on pastebin.com

Thom Parker
Community Expert
Community Expert
December 7, 2019

I saw them, and they are are not basically identical. 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Bernd Alheit
Community Expert
Community Expert
December 6, 2019

Any error message in the console?

Inspiring
December 7, 2019

It was giving me a basic "You cant read or write to this file because it's open or you don't have rights" error. I got the same from earlier versions when I was first getting into JS and it was typically my code not putting together the directory or pulling the string from a variable right (or the folders not existing, oops). But in my other script it works just fine. It's just when I put it in the while loop it does it not carry that -1 value for the switch block correctly. 

 

Idk if I'm missing something easy or if there's just some other method I need to employ to guarantee it does. Thanks for the quick reply.

 

 

Bernd Alheit
Community Expert
Community Expert
December 9, 2019

You should debug your code. With console.println( ) you can display values of variables.