handler acessing outside of itself

is it possible for a handler to continue processing an already called up file that is being read/written to?

for example:


set accessfile to myPath & "installs:prefs.txt"
set thefile to open for access file accessfile with write permission
set filecontent to (read thefile as Unicode text)

display dialog filecontent
my moreread()

on moreread()
	--do more stuff with the filecontent
end moreread

In my actuall script moreread() is called up up a bunch and I am wonderinf if this is the way to do or if there is a more efficient way of doing this

thanks elictricocean

You’re doing it correctly.
Here’s the whole scheme most commonly used.

set tFile to open for access -- etc.
try
	set myFileContents to read tFile
	--do stuff to myFileContents
	set eof to 0 -- wipes out previous content
	write myFileContents to tFile
	close access tFile
on error
	close access tFile
end try

What about this?

set accessfile to myPath & "installs:prefs.txt"
set thefile to open for access file accessfile with write permission
set filecontent to (read thefile as Unicode text)

display dialog filecontent
set filecontent to my moreread(filecontent)

on moreread(_someText)
	--do more stuff with the _someText
	return _someText
end moreread

Presumably ending up with writing it somewhere if it’s been altered, but if just used for data, fine as is.

thanks