"read file" when using framework "Foundation"

Many of my scripts include a block that reads the first eight bytes of a file in order to decide what to do with the file. This is a simplified version:

on open theDrop
	set dropItem to (item 1 of theDrop)
	set isWPDoc to false
	set isWPDoc to ((read file (dropItem as text) from 1 to 4 as data) is «data rdatFF575043»)
end open

I’m revising my scripts to use more recent technologies, and if I add these lines to the top:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"

then the script fails on the third “set” line with the error “Can’t make current application into type file” - which completely baffles me.

Is there some way I can read the first eight bytes of a file without producing this error, while still using current technologies?

In this case you should be able to simply use:

on open theDrop
	set dropItem to (item 1 of theDrop)
	set isWPDoc to false
	set isWPDoc to ((read dropItem from 1 to 4 as data) is «data rdatFF575043»)
end open

But to answer the more general question, there’s an issue with using specifiers like file. The best solution is to use «class furl». So:

read (somePath as «class furl») ...

A furl is what’s returned from choose file name, for example.

Thank you, Shane. That works perfectly. I’m revising all my scripts that use the “file read” routine.

What dismays me when I look at my twelve-year-old scripts is how needlessly complicated they are. I’m constantly coercing this into that and then finding the something of something else, when (if I had known what I was doing), I could have done it all in one step.

Seems like you are implementing the terminal file command.
/Applications/Utilities/Terminal
man file

using the file command
#not so good when compared to filetype .doc
mac $ file Back.docx
Back.docx: Zip archive data, at least v2.0 to extract

mac $ file Newsletter-April,\ 2016.doc
Newsletter-April, 2016.doc: CDF V2 Document, Little Endian, Os: Windows, Version 6.1, Code page: 1252, Author: firstname lastname, Template: Normal, Last Saved By: FirstName, Revision Number: 2, Name of Creating Application: Microsoft Word 9.0, Total Editing Time: 04:00, Last Printed: Mon Apr 11 03:54:00 2016, Create Time/Date: Mon Apr 18 04:34:00 2016, Last Saved Time/Date: Mon Apr 18 04:34:00 2016, Number of Pages: 1, Number of Words: 846, Number of Characters: 4825, Security: 0
mac $