• 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
Finding \t, \r, \n reliably
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Finding \t, \r, \n reliably


  • Subject: Finding \t, \r, \n reliably
  • From: "Grimm, Kenneth" <email@hidden>
  • Date: Fri, 21 Oct 2005 17:26:46 -0400

All,

I'm perplexed. I have a text file I read into a variable, and if the ending
of the file ends with \t\r\n I want to take those off.

When in Script Debugger, I can type the "\n" in the if statement, compiles
to its invisible representation, and it finds the character just fine.
However, on subsequent runs (the text file read doesn't change at all) it
never finds the character! I hand-type it in again, compile, and then it's
OK, until the next run.

Here's the code:

--open the file, get the files contents
open for access file foo without write permission
set AdInfo to read file foo
close access file foo
-- for debugging: return characters -1 thru -5 of AdInfo --->> {"3", "3",
"\t", "\r", "\n"} so they are there

the following is only executed once after compile, then it never evaluates
to true, although the file has never changed. A new compile, and it
evaluates true once...

--check end of file
if character -1 of AdInfo is "\n" then
   set AdInfo to ((characters 1 thru -4 of AdInfo) as string)
end if

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Finding \t, \r, \n reliably
      • From: Christopher Nebel <email@hidden>
  • Prev by Date: Re: Change a folder to list view
  • Next by Date: Re: Finding \t, \r, \n reliably
  • Previous by thread: Re: Address Book label properties
  • Next by thread: Re: Finding \t, \r, \n reliably
  • Index(es):
    • Date
    • Thread