Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Looping Code Error looking for a document
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Looping Code Error looking for a document

 Post Reply Post Reply
Author
Doc_45 View Drop Down
New Member
New Member


Joined: 19 Feb 2014
Points: 1
Post Options Post Options   Quote Doc_45 Quote  Post ReplyReply Direct Link To This Post Topic: Looping Code Error looking for a document
    Posted: 19 Feb 2014 at 4:29am
The following code generates an error when checking to see if a document exists. I have highlighted the section with stars where it is falling over. This code worked for years then stopped, then 6 months ago started again. I assumed Adobe playing around with security issues.

Any clues would be appreciated, as I am a newby and taught myself this code.


function GAddDP()
{
     var aFiles = new Array("_Map_A.pdf","_Map_B.pdf","_Map_C.pdf","_Map_D.pdf","_Map_E.pdf","_Map_F.pdf","_Demo.pdf","_Bus.pdf","_Spend.pdf");
     var cnewfile = new Array(8)

     var aPathComps = this.path.split("/");               // Path
     var myFileName = aPathComps.pop();               // Filename
     var fileNmRoot = myFileName.split(".").shift();          // Root Filename
     var strNewPath = aPathComps.join("/");               // Append path to File to Insert

for ( var i=0; i < aFiles.length; i++) {               // Loop through Array
     var fileNmNew = fileNmRoot + aFiles               // File to Insert
     //console.println(fileNmNew);
     cnewfile = strNewPath + "/" + fileNmNew          // Combine All
     //console.println(cnewfile);
     }
//**************************************************************
for ( var i=0; i < cnewfile.length; i++) {               // Loop through the list of filenames
     var nfileexists = 1;
     try{
     var otherDoc = app.openDoc(cnewfile);          // Test if File exists
     }catch(e){
        nfileexists = 0;                         // Catch the errror if it doesnt
     }
//**************************************************************
if (nfileexists > 0)
     {
     otherDoc.closeDoc();                              // If it exists close it
     this.insertPages({nPage:this.numPages-1,cPath:cnewfile});     // Insert the document if it exists
     }
     }
//*** Front Cover
     var fileNmNew2 = fileNmRoot + "_Cover.pdf"          // File to Insert
     var cnewfile2 = strNewPath + "/" + fileNmNew2          // Combine All
try{
     var nfileexists = 1
     var otherDoc = app.openDoc(cnewfile2);
     }catch(e){
        nfileexists = 0;
     }
if (nfileexists > 0)
     {
     otherDoc.closeDoc();
     this.insertPages({nPage:-1,cPath:cnewfile2,nStart: 0 });
     }
app.alert({cMsg: "     Data Pack Append Completed !",cTitle: "Geotech Data Packs"});
}

Thanx Mark

Back to Top
Sponsored Links


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.049 seconds.