Can't set top to text 1 through (off_set - 1) of theData.

So thats the error and here is what I’m trying to do…

to some_function()
	--this compiles and putting a display dialog in there shows off_set having the correct value
	set theData to read file (contents of text field "tf_filePath" of window "SelectWindow")
	set off_set to offset of "%SOME STRING%" in theData
	
	-- this errors out with the message "Can't set top to text 1 through (off_set - 1) of theData. Access not allowed"
	set top to text 1 through (off_set - 1) of theData
end some_function

So why this wont compile is absolutely beyond me… Any ideas? The same code (removing the portion of the contents and specifying the path of course) works in Script Debugger, but not in AS Studio :frowning:

Thanks!

Wouldn’t your guess be that top was a keyword in ASS applescript?

Of course not Adam that would be too easy ::hangs head::