file.close() undefined?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

I have a short script to launch another script(seems silly huh?). Everything works out OK up to the last line. I'm getting a "theFile.close function is undefined". It doesn't look like I'm doing anything wrong but I have no idea why it's giving me that error.

Code: Select all

var fileLoc = "";
//alert("inside after effects");
if (app.settings.haveSetting("ImagesLLC Photo Montage", "ScriptLocation")) {
	fileLoc = new File(app.settings.getSetting("ImagesLLC Photo Montage", "ScriptLocation"));
}
	if(fileLoc.exists){
		theFile = fileLoc;
	}else{
		var theFile = fileGetDialog("Please find the Montage Script...", "");
	    app.settings.saveSetting("ImagesLLC Photo Montage", "ScriptLocation", theFile.toString())
  	}
//var scriptFile = new File(theFile);
theFile.open();
eval(theFile.read());
alert(theFile);
theFile.close();
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

Hi Byron...

I can't repro the problem here. Maybe there's some error the script you're trying to launch that's either undefining theFile or something?

Maybe add some exception handling (try/catch block) or just delay the eval() until after the close(), as in:

Code: Select all

theFile.open();
var fileContent = theFile.read();
theFile.close()
eval(fileContent);
BTW, if the pref wasn't previously saved, the fileLoc variable is a string, not a File object, which you're trying to check .exists. That's what I originally thought was the problem, but it would've displayed an error on the .open() call.

Hope this helps.

Jeff
Post Reply