• 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
Re: applescript & TextEdit : selecting minus sign (-) for type conversion?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: applescript & TextEdit : selecting minus sign (-) for type conversion?


  • Subject: Re: applescript & TextEdit : selecting minus sign (-) for type conversion?
  • From: CYB <email@hidden>
  • Date: Fri, 17 Apr 2009 14:10:50 -0500
  • Thread-topic: applescript & TextEdit : selecting minus sign (-) for type conversion?

Title: Re: applescript & TextEdit : selecting minus sign (-) for type  conversion?
Hi everyone , my first post :
I have a text file with a large quantity of real numbers , both positive and negative
and want to write an applescript to get TextEdit to  round them to integers. (then rewrite a copy file - this i can do)

** but I'm losing the minus sign information **!!


using this code:
------------------------------------------------------------------------
tell application "TextEdit"
             --file is open already
         set the_doc_text to text of the front document
end tell

     -- loop through lots of values with integer count W.....

set the_word to word W of the_doc_text
set the_int to the_word as integer

     -- and write the_int  etc.

------------------------------------------------------------------------

if i have as a text file :

37.147   -4.041    -3.4591   10.805    -0.439    -1.733
i get:

37            4            3            10             0            1

------------------------------------------------------------------------
the minus sign is not selected by the "word" applescript command-

how can i get those signs back in my  output ?


thanks in advance

Laura

email@hidden

Laura
   
if your text is, for example, separeted by tabs, using your info
        37.147    -4.041    -3.4591    10.805    -0.439    -1.733
    then you will have this solution.
    of course you can use whatever text item delimiter you want

--Script
tell
application "TextEdit"
   tell document 1
       set t to text of it
   end tell
end
tell
set
oldTID to AppleScript's text item delimiters
set
AppleScript's text item delimiters to {tab}
set lista to text items of t
set AppleScript's text item delimiters to oldTID
set ListIntegers to {}
repeat with i from 1 to count t
   try
       set end of
ListIntegers to (item i of lista as integer)
   end try
end
repeat
ListIntegers
--» {37, -4, -3, 11, 0, -2}
-- End of Script


Carlos Ysunza B.
Director
Ysunza/Santiago
Comunicación Visual • Automatización
Tel. (52)55 5256-0336
email@hidden

http://www.ysunzasantiago.com
http://www.thesecretmexico.com
http://www.softrobot.com.mx

 _______________________________________________
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

References: 
 >applescript & TextEdit : selecting minus sign (-) for type conversion? (From: Laura Burns <email@hidden>)

  • Prev by Date: Re: Simply deleting a fil
  • Next by Date: Re: Simply deleting a fil
  • Previous by thread: Re: applescript & TextEdit : selecting minus sign (-) for type conversion?
  • Next by thread: Re: Recycling Email Drafts in Mail
  • Index(es):
    • Date
    • Thread