This content has been marked as final. Show 11 replies
It can be very confusing when you use an alert like this to test an assumption. The alert code is quite smart. It knows it can only post a string to the alert dialog, so it bends over backwards to convert whatever you send it into a string.
So, chances are that myReport is not a string (I've not done any actual coding with this part of the object model) but something else which when forced to a string by the alert code comes out as "None".
Put a breakpoint before the alert and use ESTK's data browser to work out what's going on.
I haven't used the Data Browser up to now but I have done what you suggested and can see the reference to myReport at the end of the list in the Data Browser.
The value alongside it is None.
I am not sure if I am looking at the right thing.
Can you suggest a good resource for learning to use the ESTK.
You are looking at the right thing. There is a guide available in ESTK's Help menu that's pretty good, I think.
into the Console and see what you get. If it says String, then there must be an invisible character in there of some kind.
Yes, it does give String as the result. How do I go about finding the hidden character.
Or is there another way of testing if a Preflight has no errors?
I will definately commit to learnig more about the ESTK.
Instead of sending it to an alert, insert it into an empty InDesign text frame and then see what appears.
Assuming you prime an insertion point before running your script, all you have to do is replace the alert with:
app.selection.contents = myReport;
This gives "None" followed by a paragraph mark and then a forced line break.
Can I test just the first 4 characters for a match?
Dave,1 person found this helpful
var myPreflight = app.preflightProcesses;
var myReport = myPreflight.processResults;
var myTest = myReport.indexOf("None");
if (myTest == 0)
alert ("No errors found");
alert ("Errors found");
If there are no preflight errors then myTest returns "0", if there are any preflight errors found then myTest returns "-1".
Thank you for your time and for pointing me in the right direction.
The toSource() function is often helpful in such cases.
Native objects just yield a "resolve...", use their properties property to drill down.
Of course, instead of alert() there is also the ESTK console.
I would strip out trailing white space like this:
myReport = myReport.replace(/\s+$/, '');
I like this approach. I recognise this as Grep and I know that \s+ is any sequence of whitespace, tabs and returns. But what does $ do? And the first and last / ?
The "$" means only at the end of the string.