Friday, January 28, 2022

#1 2021-10-19 04:17:10 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 521

"read POSIX file" breaking when I "use framework "Foundation""

I have a library handler that read a text file generated by another script. It stores an Applescript record in the test file for information passing between scripts. It reads the file in with the line:

Applescript:

set existingRecord to read POSIX file recordLocation as record

Which has been working fine for years....

then today I add a new, unrelated handler that contains some ASObjC code, so at the top of the library, I add:

Applescript:

use framework "Foundation"

Now when the handler gets to the line:

Applescript:

set existingRecord to read POSIX file recordLocation as record

It errors:

Can’t make current application into type file.



Apparently there's some terminology conflict there, where it's attempting to evaluate my Applescript code as ASObjC code, and it's failing? But I don't understand why. Can someone please explain why it's failing, and also how I fix it?

Thanks.


Ditched the Hackintosh.
Intel Mac Mini i7 and M1 Mac Mini on a KVM.

Offline

 

#2 2021-10-19 05:13:35 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6748

Re: "read POSIX file" breaking when I "use framework "Foundation""

The issue is discussed here:

https://latenightsw.com/adding-applescr … g-scripts/

Although that refers to using file, the issue also affects POSIX file.

So:

Applescript:

set existingRecord to read (recordLocation as POSIX file) as record


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2021-10-19 07:23:46 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 521

Re: "read POSIX file" breaking when I "use framework "Foundation""

Thank you Shane, very helpful, great link.

Still, this is highly unintuitive behavior on Apple's part.


Ditched the Hackintosh.
Intel Mac Mini i7 and M1 Mac Mini on a KVM.

Offline

 

#4 2021-10-19 07:55:00 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6748

Re: "read POSIX file" breaking when I "use framework "Foundation""

t.spoon wrote:

Still, this is highly unintuitive behavior on Apple's part.



I suspect it's entirely unintentional, but something to do with the fact that both furl and old-style file references compile to the term file.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)