POSIX paths and variables

I want to locate files from across a network. I’m fairly new to Applescript

Assuming the volume server is mounted and test_file.txt exists where it’s supposed to:

How come this works:

tell application “Finder”
if POSIX file “volumes/server/documents/test_file.txt” exists then
return true
else
return false
end if
end tell

The script returns true, which is what it should do.

But this doesn’t work:

tell application “finder”
set pathOfFile to “volumes/server/documents/test_file.txt”
if POSIX file pathOfFile exists then
return true
else
return false
end if
end tell

This returns false, even though the file exists. Why doesn’t applescript like the variable?

The reason I’m asking is I’d like to automate moving files between networked computers using afp:// .

Thanks!

Model: iMac 2009
AppleScript: 2.0.1
Browser: Firefox 3.5.3
Operating System: Mac OS X (10.5)

Since POSIX path is from an OSAX, it is best to avoid using it inside application tell blocks.
Try one of these variations:

set pathOfFile to "/volumes/server/documents/test_file.txt"
set fileRef to POSIX file pathOfFile
tell application "Finder"
	if fileRef exists then
		return true
	else
		return false
	end if
end tell

OR

set pathOfFile to "/volumes/server/documents/test_file.txt"
tell application "Finder"
	if (my POSIX file pathOfFile) exists then
		return true
	else
		return false
	end if
end tell

Also, as I have done above, it is probably a good idea to include the leading slash in the POSIX pathname.

You, sir, are a lifesaver. Thank you!