this is extendscript for illustrator, its basically javascript though. I want the second pop up to only show once, I tried to tell it if the variable already exists to not do it, but if it doesn’t to ask for input. any idea what I am doing wrong?
#target illustrator
if ( app.documents.length > 0 ) {
var replaceThis = prompt('What font do you want to replace?','')
for ( i = 0; i< app.activeDocument.textFrames.length; i++) { //loop through the layers
var textArtRange = app.activeDocument.textFrames[i].textRange;
var fontSize = textArtRange.characterAttributes.size;
//var replaceThis = "10";
//alert("replace this:" + replaceThis);
// alert("current font size" + fontSize);
if (fontSize == replaceThis) {
Replacefont();
}
function Replacefont () {
//var newSize = "90";
if (!newSize) {
var newSize = prompt('Replace '+ replaceThis +'pt with:','')
}
textArtRange.characterAttributes.size = newSize;
alert("yay");
}
}
}
newSizeis only available insideReplaceFont, and is discarded each time the function ends. You’d need to make it persistent like this (there is no real reason for making a separate function). Also don’t forgetvarfor theforloop.