Copy link to clipboard
Copied
Hi experts,
my script like this:
var
cName, mLinks, cLink, matchCount = 0,
checkLinkName,
manual = false;
if (cFile.name.match(/\.indb/i))
manual = true;
else {
mLinks = cFile.links.everyItem().getElements();
while (cLink = mLinks.shift()) {
cName = cLink.name.match(/[ec]\d{4}_..\.eps/);
if (!cName.length) continue;
cName = cName[0].split(/_..\.eps/)[0];
matchCount++;
}
if(matchCount > 1 || matchCount == 0) manual = true;
}
if (manual)
cName = mDialog ();
cTime = new Date;
if (!File(cPath.exists))
Folder(cPath).create();
cName += ".pdf";
return File(cPath + cName);
}function mDialog ()
{
var
w = new Window("dialog","Input Stock Code", undefined, {closeButton: false}),
p = w.add("panel"),
mLine = p.add("group"),
mStat1 = mLine.add("statictext", undefined, "Stock code:"),
mEdit1 = mLine.add("edittext", undefined, ""),
mB = w.add("group");
mB.add ('button', undefined, "取り消す", {name: "Cancel"});
mB.add ('button', undefined, "OK", {name: "OK"});
mLine.alignChildren = "left";
mEdit1.characters = 8;
mB.spacing = 50;if (w.show() == 1)
return Number(mEdit1.text);
else exit();
}
it is error on :
if (!cName.length) continue;
How can I fix it.
Thanks
Regard
John
Use
if (!cName || !cName.length) continue;
The issue is that the match method call above it can also result in a null result and accessing property on a null results in an error
-Manan
Copy link to clipboard
Copied
You forgot to add what the error is ...
Copy link to clipboard
Copied
Hi Jongware
the error reason is:
null is not an object
John
Copy link to clipboard
Copied
Use
if (!cName || !cName.length) continue;
The issue is that the match method call above it can also result in a null result and accessing property on a null results in an error
-Manan
Copy link to clipboard
Copied
thank you Manan
thank so much.
John