Using MainEvents to script Plugin Acrobat

I just upgraded to Panther, and now some of my scripts are giving me an end of file error where I got no error before. The gist of it is that I write information to a file (usually as a list), and then read it again later as a list. Here’s the code that gets the error:

set songInfoFile to alias “Macintosh HD:Users:me:Documents:songFile.txt”
set theInfo to read songInfoFile as list

Any idea how to fix this?

-RJ

Can you post a sample of the contents of the file? How large is the file? Does this work?

set theInfo to paragraphs of (read songInfoFile)

– Rob

I’m having the same problem since I’ve been updating a script from it’s OS9 version to 10.3.2. These subroutines are used to save and load preferences for the program, basically a small list of file names and booleans. It happens very inconsistently, sometimes it works fine but sometimes I get an ‘end of file error’ when reading the file. It always worked perfectly with OS9.

set pref_path to (((path to desktop) as string) & “ColorSync Convertor ƒ:” & “ColorSyncConvPrefs.txt”) as file specification

–READ DATA FROM FILE
on read_this_file(file_path)
try
copy (open for access file_path) to file_ref
set retrieved_info to read file_ref as list
return the retrieved_info
close access file_ref
on error
close access file_ref
return false
end try
end read_this_file

–WRITE DATA TO FILE
on write_to_file(this_data, target_file_path, append_file)
try
set the open_target_file to open for access target_file_path with write permission
if append_file = false then
set eof of the open_target_file to 0
write (this_data) to the open_target_file as list starting at eof
else
write (this_data) to the open_target_file starting at eof
end if
close access the open_target_file
on error
try
close access the open_target_file
end try
end try
end write_to_file


Is the file being closed again after it’s been written to? If it’s still open, the file position pointer will be at the end of the file and your code will produce that error.

Don’t use ‘return’ before you close the file! :slight_smile:

There’s no reason to open a file just to read it any way:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Thanks for your help guys, that seems to have cured my problem.
Best wishes for the new year. :lol:

Hi,

I downloaded MainEvents 1.3.1 and changed the sample script to script adobe acrobat.
It tells acrobat to show a dialogbox, this is a dialogbox of a plugin calls
“Enfocus Pitstop” wich we use to check PDF files. The script works till the dialogbox
show up, is it possible to script things in this dilaogbox with MainEvents??


tell application "Finder"
	if exists items in folder "Dolf HD:Desktop Folder:PDFF:" then
		set theFolderList to folder "Dolf HD:Desktop Folder:PDFF:"
		set theNameList to ""
		repeat with thisItem in theFolderList
			set theNameList to (the name of thisItem)
			tell application "Acrobat 5.0"
				activate
				open thisItem
			end tell
			exit repeat
		end repeat
	end if
end tell
tell application "Finder"
	set targetApplication to application "Acrobat 5.0"
	tell targetApplication
		try
			set menuListInfo to Query Menu List
		end try
		if (count of menuListInfo) is greater than 0 then
			set menuListText to menu title of item 1 of menuListInfo
			repeat with menuIndex from 2 to count of menuListInfo
				set menuListText to menuListText & ", " & menu title of item menuIndex of menuListInfo
			end repeat
		end if
		set menuInfo to Query Menu menu title "Certified PDF"
		Select Menu Item menu title "Certified PDF" menu item text "Edit Properties..."
	end tell
end tell