Reputation: 31
Any ideas why sometimes when the script is called to run it will launch ExtendScript Toolkit & just stall? I think it maybe when there is a lot of text to go through. Not sure that is the case every time. See Pic below script.
If it stops it stops on the line: var new_string = this_text_frame.contents.replace(search_string, replace_string);
// Version 3
function myReplace(search_string, replace_string) {
var active_doc = app.activeDocument;
var text_frames = active_doc.textFrames;
if (text_frames.length > 0)
{
for (var i = 0 ; i < text_frames.length; i++)
{
var this_text_frame = text_frames[i];
var new_string = this_text_frame.contents.replace(search_string, replace_string);
if (new_string != this_text_frame.contents)
{
this_text_frame.contents = new_string;
}
}
}
}
myReplace(/^PRG.*/i, "");
myReplace(/.*EBOM.*/i, "");
myReplace(/^PH.*0000.*/i, "");
myReplace(/^PH.*00\/.*/i, "");
// N or W & 6 #'s & -S_ EX. N123456-S_ REPLACE with: N123456-S??? (THIS NEEDS TO BE ABOVE _ REPLACED BY SPACE)
myReplace(/([NW]\d{6}-S)_/i, "$1??? ");
myReplace(/_/gi, " ");
// 6 #'s & - or no - & 7 #'s & 1 to 3 #'s & - EX: 123456-1234567/123- REPLACE with: -123456-
myReplace(/(\d{6})-?\d{7}\/\d\d?\d?-/i, "-$1-");
myReplace(/(\d{6})-?\d{7}-\/\d\d?\d?-/i, "-$1-");
myReplace(/([NW]\d{6}-S)-INS-\d\d\/\d\d?-/i, "$1??? ");
myReplace(/-INS-\d\d\/\d\d?-/i, "* ");
// - That is only followed by one more - & Not having PIA & - & 2 to 3 #'s & / & 1 to 3 #'s & - EX: -7NPSJ_RH-001/9- REPLACE with * & Space
myReplace(/-[^-]*-\d\d\d?\/\d\d?\d?-/i, "* ");
myReplace(/ ?ASSEMBLY/gi, " ASY");
myReplace(/ ASS?Y+$| ASS?Y - | ASS?Y -| ASS?Y | ASS?Y- | ASS?Y-/gi, " ASY - ");
myReplace(/(MCA-|DS-?C1-?)/i, "-");
myReplace(/^DS-|^DI-|^PH-|MCA|^PAF-|^PAF|^FDR-|^FDR/i, "");
myReplace(/VIEW ([a-z])/i, "TTEMPP $1");
myReplace(/ ?\(?V?I?EW\)| ?\(?VIE[W)]?|^W\)| ?\(VI+$|^ ?\(VI| ?\(V+$|^ ?\(V| ?\(+$|^ ?\)/i, "");
myReplace(/TTEMPP ([a-z])/i, "VIEW $1");
myReplace(/([NW]\d{6}-S)-/i, "$1??? ");
myReplace(/([NW]\d{6}-S)\/.-/i, "$1??? ");
// Needs to be in this order
myReplace(/ AND /i, "&");
myReplace(/WASHER/i, "WSHR");
myReplace(/BOLT/i, "BLT");
myReplace(/STUD/i, "STU");
myReplace(/([SCREW|SC|NUT|BLT|STU])&WSHR/i, "$1 & WSHR");
myReplace(/\?\?\? SCREW &/i, "??? SC &");
myReplace(/\?\?\? SC [^&]/i, "??? SCREW ");
myReplace(/(\?\?\? SC & WSHR).*/i, "$1");
myReplace(/(\?\?\? SCREW).*/i, "$1");
myReplace(/(\?\?\? NUT & WSHR).*/i, "$1");
myReplace(/\?\?\? NUT [^&].*/i, "??? NUT");
myReplace(/(\?\?\? BLT & WSHR).*/i, "$1");
myReplace(/\?\?\? BLT [^&].*/i, "??? BLT");
myReplace(/(\?\?\? STU & WSHR).*/i, "$1");
myReplace(/\?\?\? STU [^&].*/i, "??? STU");
myReplace(/--/gi, "-");
if ( app.documents.length > 0 && app.activeDocument.textFrames.length > 0 ) {
// Set the value of the word to look for
searchWord1 = "*";
//searchWord2 = "The";
// Iterate through all words in the document
// the words that match searchWord
for ( i = 0; i < app.activeDocument.textFrames.length; i++ ) {
textArt = activeDocument.textFrames[i];
for ( j = 0; j < textArt.characters.length; j++) {
word = textArt.characters[j];
if ( word.contents == searchWord1 ) {
word.verticalScale = 120;
word.horizontalScale = 140;
word.baselineShift = -3;
}
}
}
}
[img]http://i.imgur.com/9IRy9.jpg[/img]
This javascript is call to run from a applescript.
set Apps_Folder to (path to applications folder as text)
set Scripts_Path to "Adobe Illustrator CS5:Presets.localized:en_US:Scripts:"
set JS_FileName to "Text Find & Replace.jsx"
--
try
set JS_File to Apps_Folder & Scripts_Path & JS_FileName as alias
tell application "Adobe Illustrator"
do javascript JS_File show debugger on runtime error
end tell
on error
display dialog "Script file '" & JS_FileName & "' NOT found?" giving up after 2
end try
Upvotes: 3
Views: 2343
Reputation: 1858
While I'm sure @fabianmoronzirfas has the technically correct and most likely answer, my recent experience with error 1346458189
is that is appears to be Illustrator's equivalent of Microsoft's infamous "Unknown error." That is, it appears to be the catch-all error for anything Adobe didn't write a more informative error trap for.
For me, this unhelpful error was a result of trying to set the artboard too small (below 1 point). Clearly, Illustrator doesn't do enough bounds checking. For others, as far as I could tell from searching the net, it comes from a smattering of reasons. Including, possibly, memory and other errors from within Illustrator's script processor, which would be one way to account for it's randomness in some scenarios. Most likely, however, I suspect it is usually something solvable with more durable code.
Upvotes: 1
Reputation: 11
Its not "MRAP", its "PARM" but the number fits.
actually, on MacOS "MRAP" is the correct sentence returned. "PARM" is for windows.
My experience with this error :
I run a 2 000 lines' javascript.
I have to check for 700 folders contained each between 1 - 15 differents .ai files.
on MACOS 10.7, I got this error 2 times for 15 folders, never the same file. (CS6)
on Win8 I got this error 1 time for 5 folders, never the same file. (CC 2014)
on win7 I got this error 1 time for 100 folders, never the same file. (CC 2014 or CS6)
and finally I run it on a just installed win7 and I got no error, the script was running 10 hours without interruption. (CC 2014 or CS 6)
Upvotes: 1
Reputation: 4121
Did you search for your Errorcode?
1346458189 ('MRAP')
It is at the bottom of the ESTK. have a look here http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scripting/cs6/Readme.txt
Its not "MRAP", its "PARM" but the number fits.
"An Illustrator error occurred: 1346458189 ('PARM')" alert (1459349)
Affects: JavaScript
Problem:
This alert may appear when carelessly written scripts are repeatedly
run in Illustrator from the ExtendScript Toolkit.Each script run is executed within the same persistent ExtendScript
engine within Illustrator. The net effect is that the state of
the ExtendScript engine is cumulative across all scripts that
ran previously.The following issues with script code can cause this problem:
- Reading uninitialized variables.
- Global namespace conflicts, as when two globals from different
scripts have the same name.
In your script are some uninitialized variables
searchWord1 = "*";
textArt = activeDocument.textFrames[i];
word = textArt.characters[j];
Upvotes: 1