I try to check for local files (.jpg) using a plain js loop. I get an error that, for example, file 5d3eb1905b243.jpg does not exists, but actually it does.
Also, I don't understand why the else statement ins't working and why 5d3eb1905b243.jpg isn't replaced with none.jpg.
Maybe the path is the problem?
Here's the code:
if (obj[i].hasOwnProperty('sharedimage_id')) {
var imgFile = new File(
'/Users/student/Desktop/seminar_robobooks/archiv/img/' +
obj[i].sharedimage_id +
'.jpg',
);
if (imgFile.exists) {
noStroke(imgFile);
image(obj[i].sharedimage_id + '.jpg', 56.5, 70.793, 69, 42);
} else {
noStroke(imgFile);
image('none.jpg', 56.5, 70.793, 69, 42);
}
}
You are not providing enough context to your question.
FileorXMLQuestion: Which Basil version are you using? v2 (still in Beta)?
Below is a little more boilerplate code to keep discussing and some pointers.
noStrokedoes not get an argument see thisnone.jpgneeds to be in the data dir next to the InDesign Document you are executing against or you need to provide a absolute path See thisP.S. I'm one of the authors and I'm linking to the current development version of the Reference. The links might break in the future.