Pausing script until user interaction
Hey everyone!
I wrote a script that is a part of bigger script and my export action
It checks if job is for one of my two clients (based on text frames content), then if layer named "farmakod" exists, then if "farmakod" is empty.
var docRef = app.activeDocument;
function doesLayerExist(layers, name) {
for (i = 0; i < layers.length; i++) {
if (layers.name == name) return true;
}
return false;
};
function checkPharmaCode() {
if (doesLayerExist(docRef.layers, "farmakod")) {
var targetLayer = app.activeDocument.layers.getByName("farmakod");
if (targetLayer.pageItems.length == 0) {
alert("Missing pharmacode on 'farmakod' layer!");
} else {};
} else {
alert("Missing layer 'farmakod'!")
}
};
function checkPharmacy() {
var frames = docRef.textFrames;
for (var x = frames.length - 1; x >= 0; x--) {
if ((frames
.contents.indexOf("CLIENT1") > -1) || (frames .contents.indexOf("CLIENT2") > -1)) { checkPharmaCode()
} else {}
}
};
checkPharmacy();
Right now i only have an alert information, but the script (and action) are stil going after closing an alert.
And since the script is exporting my file as pdf, i dont want to wait until the end of the proccess, just to fix everything, and start script once again.
I was doing some searching and as far as i know there is no simple way to stop a script to let user make some changes (in my ex. creating a layer and inserting a content).
Palette window is not an answer - i can do my changes, but script is still working
Dialog window - stops a script, but doesn't allow to click anything besides window itself.
Is there any workaround for this issue?
Like setting $.sleep for 10min, and after clicking OK on palette window the $.sleep would be interrupted or changed to 0?
Or something like clearTimeout ?
Also some code review would be appreciated ![]()
Sorry for my english.
