Are there folders in a directory? what's wrong w/ this??

writing a function, returns a bool if there are more folders in a directory passed in.


to MoreExists(f)
	set f to f as alias
	tell application "Finder" to set len to length of name of folders of folder f  -->HERE'S WHERE I GET THE ERROR
	if len = 0 then
		return false
	else
		return true
	end if
end MoreExists

Try…

tell application "Finder" to set len to count folders of folder f 

j

I’m getting the following error

here’s the if statement using the function

if MoreExists(myPath2 & select_cat & ":" as string) then
--do stuff

and here’s the modified function

to MoreExists(f)
	tell application "Finder" to set len to count folders of folder f
	if len = 0 then
		return false
	else
		return true
	end if
end MoreExists

Thanks so much…I’m just really puzzled here.

I have no problems with the following test code…

set myPath2 to "Macintosh HD:"
set select_cat to "Library"
set theTest to (myPath2 & select_cat & ":") as string

try
	if MoreExists(theTest) then
		display dialog "Subfolders exist"
	else
		display dialog "No subfolders exist"
	end if
on error
	display dialog "Folder didn't exist"
end try

to MoreExists(f)
	tell application "Finder" to set len to count folders of folder f
	if len = 0 then
		return false
	else
		return true
	end if
end MoreExists

It’s not clear how you are obtaining all of your variables, but make sure you are providing valid values to your subroutine. For instance, make sure that you are passing “Library” and not “Library:” and so on. I would coerce the path you’re checking into it’s own variable (var ‘theTest’) before you evaluate it, too…so it’s clear what you intend to evaluate. I’m not sure why you’re getting the “class menI” error. I believe that is a menu item error, which leads me believe it’s a problem with your interface (probably a menu item?!), not with your actual evaluation code.

j

Thanks jobu for all your trying…
I’ve checked all of the syntax for errors such as “Library:” vs. “Library”…but everything seems to be clean.

I did catch one problem…I had forgotten to link the third dropbox from the interface to the code, but after fixing that I still have the same error.

Is there some way I could send you my project and have you take a look at the whole thing…I am just really stumped here. It’s not that big…just over 100 lines and one NIB.

If so, where should I send it, and which files/folders do you need?

I would really appreciate the help.

Sure, send it to…

jobu10000 (a) yahoo . com

Send the entire project, the folder containing all of the files related to the project.

j