Help with list length please

Hi There,

I’ve put together a script that processes files dropped onto it. Successfully processed files have their filename added to a list that is output to a text file at the end. I’ve been trying to get the number of filenames in the list but keep getting odd results. The script is roughly this:-

on open someitems
	set donelist to {}
	repeat with theitem in someitems
		--process file in some way
		set donelist to (donelist & filename of theitem)
	end repeat
	display dialog (length of donelist)
end open

Hopefully you’ll get the idea from that.

I’m not sure if it’s something to do with Applescripts text item delimiters?

Can someone help please?

Thanks

Nick

I don’t believe so.

Does this work any better for you?

on open theseItems
	set doneList to {}
	
	repeat with thisItem in theseItems
		set thisName to name of (info for thisItem without size)
		
		--process file in some way
		
		set doneList's end to thisName
	end repeat
	
	display dialog (count doneList)
end open

What are the odd results your seeing?

How about

display dialog (count of items of doneList)

Edit

Bah, Bruce beat me to it

Thanks for the speedy replies guys.

I’m still getting some weird numbers. If I process 2 files ‘comments_test copy 121.pdf’ and ‘comments_test copy 122.pdf’ I get the value 70 returned, not 2, which it should be.
When I calculate the number of chars in both filenames and a header line I get something near to 70.

Any more ideas?

Thanks again,

Nick

You need to tell use what you’re doing when you “process file in some way.”

(If the count is off then doneList’s problem occurs earlier.)

Hi Bruce,

Have thought of a way I might be able to get round the problem. I’ll give it a quick try to see if it works.

Thanks again for the help.

Nick

You’re turning doneList into text:

set doneList to (doneList & return as text)

You don’t need the as text part.