• 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: tabs to spaces
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tabs to spaces


  • Subject: Re: tabs to spaces
  • From: Scott Haneda <email@hidden>
  • Date: Mon, 1 Dec 2008 23:27:46 -0800

On Dec 1, 2008, at 8:46 PM, Mark J. Reed wrote:

set oldTID to text item delimiters -- don't assume you know what they are
set text item delimiters to tab
set rows to {} -- need this one since we're appending later
repeat with a_line in lines
set cells to text items of a_line
set end of rows to cells
end repeat
set text item delimiters to oldTID
rows


The "set end of rows" is the key - that appends a new element to the
"rows" list, which is itself a list of fields.  You could also do it
in one swell foop
without the "cells" variable:

set end of rows to text items of a_line


This is working quite well for me at this point. Testing to add one final feature, which is to modify the data in each "cells" in place, and stuff the result right back into the list, in the same place:

I have a small function
strPadRight(string, length, pad_char)

That will do this
strPadRight("test", 10, "*")
> test**********

Any suggestions on how to add that into the repeat loop within each cell of the list items. So {{"d***", "c***"}, {"a***", "b***"}}
would become {{"d***", "c***"}, {"a***", "b***"}}


--Start the actual work on the data in the clipboard
set the_lines to paragraphs of current_clipboard

set oldTID to text item delimiters
set text item delimiters to tab
set rows to {}
repeat with a_line in the_lines
	set cells to text items of a_line
	set end of rows to cells
end repeat
set text item delimiters to oldTID
rows
--
Scott

_______________________________________________
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: 
 >Re: tabs to spaces (From: Scott Haneda <email@hidden>)
 >Re: tabs to spaces (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: specifying "text" language
  • Next by Date: Re: tabs to spaces
  • Previous by thread: Re: tabs to spaces
  • Next by thread: Re: tabs to spaces
  • Index(es):
    • Date
    • Thread