Article View: adobe.scripting.indesign
Article #15522Re: Undefined Object Blues
From: Dave_Saunders
Date: Sat, 22 Nov 2003 16:53
Date: Sat, 22 Nov 2003 16:53
76 lines
2541 bytes
2541 bytes
My first try was:
try {
myFormatsFrame = myTempGroup.textFrames.item('FormatFrame');
ppos = 0;
} catch (e) {
myFormatsFrame = mySource;
ppos = j + 1;
}
But, even though the frame I'm looking for doesn't exist in myTempGroup, JavaScript ploughs merrily on by simply making myFormatsFrame undefined.
OK:
myFormatsFrame = myTempGroup.textFrames.item('FormatFrame');
ppos = 0;
if (myFormatsFrame.constructor.name != "TextFrame") {
myFormatsFrame = mySource;
ppos = j + 1;
}
But that doesn't work because you can't get myFormatsFrame.constructor.name because myFormatsFrame is undefined.
OK:
myFormatsFrame = myTempGroup.textFrames.item('FormatFrame');
ppos = 0;
if (myFormatsFrame == undefined) {
myFormatsFrame = mySource;
ppos = j + 1;
}
But that doesn't work. Apparently undefined is not able to be equated to some other undefined.
SO:
myFormatsFrame = myTempGroup.textFrames.item('FormatFrame');
ppos = 0;
try {
myFormatsFrame.constructor.name;
} catch (e) {
myFormatsFrame = mySource;
ppos = j + 1;
}
And that doesn't work either. Perhaps I need to try to assign the constructor name to a variable to trigger the error.
I'm starting to lose my cool:
myFormatsFrame = myTempGroup.textFrames.item('FormatFrame');
ppos = 0;
try {
myTemp = myFormatsFrame.constructor.name;
} catch (e) {
myFormatsFrame = mySource;
ppos = j + 1;
}
doesn't work either.
Aha! Let me try to get the label of it. That'll work if it's really there. Means an interaction with InDesign, but hey, we're scraping the barrel here:
myFormatsFrame = myTempGroup.textFrames.item('FormatFrame');
ppos = 0;
try {
myTemp = myFormatsFrame.label;
} catch (e) {
myFormatsFrame = mySource;
ppos = j + 1;
}
WORKED! Hallelujah!
However, the script has crapped out further on, so there's still more work to be done.
Dave
Technical Details
Message-ID:
<2cce8972.0@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2cce8972.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,5572ac4b7c018113 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-11-22 09:07:43 PST From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: Undefined Object Blues Message-ID: <2cce8972.0@webx.la2eafNXanI> Date: Sat, 22 Nov 2003 08:53:44 -0800 References: <2cce8972.-1@webx.la2eafNXanI> Lines: 84 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit