• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
read file subroutine fails every second time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read file subroutine fails every second time


  • Subject: read file subroutine fails every second time
  • From: MB <email@hidden>
  • Date: Sun, 13 Apr 2008 15:42:03 +0200

I'm trying to make a reader subroutine to use in one of my email scripts
and other places, with the objective to move the content of attached
HTML files to the HTML Content of the message in application PowerMail.
First time I run this test of my reader() subroutine it works as
expected, but the second time it gives me a EOF error (-39). How can I
avoid end of file errors in this context?


***The Reader Script
on run
choose file
	set theFile to result
	set theContent to my reader(theFile)
-- the main parts only with the call for brevity
end run

on reader(theAlias)
	try
		open for access theAlias
	on error
		display dialog "Couldn't read file " & theAlias
		return
	end try

	repeat

		try
			set theFileText to (read theAlias before (ASCII character of 30)
using delimiter (ASCII character of 28))
			return theFileText
		on error myErrMsg number myErrNo
			close access theAlias
			exit repeat
		end try

	end repeat
end reader

***End of reader Script


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: read file subroutine fails every second time
      • From: KOENIG Yvan <email@hidden>
  • Prev by Date: Re: How do I set an icon to a folder from Clipboard or png file
  • Next by Date: BBEdit Preview
  • Previous by thread: Re: How do I set an icon to a folder from Clipboard or png file
  • Next by thread: Re: read file subroutine fails every second time
  • Index(es):
    • Date
    • Thread