• 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
Convert any list to a table?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Convert any list to a table?


  • Subject: Convert any list to a table?
  • From: Jason Bourque <email@hidden>
  • Date: Tue, 18 Sep 2001 22:53:53 -0400

Ok, before I pull out any hair.

--So how do you create a false table with tabs from a list and
--not have an extra character at the end. Plus handle even and odd lists?
--And handle any number of columns.

--Below is my code that works for a 2 column table.

--Thanks

--Jason Bourque


on createFalseTable(anyList, columnsNeeded)

set anyListCount to count of anyList

set rowsNeeded to (anyListCount div columnsNeeded) + (anyListCount mod
columnsNeeded)

set newList to {}
repeat with rowsNth from 1 to rowsNeeded

repeat with columnNth from 1 to columnsNeeded
try
item ((columnNth * rowsNeeded) - rowsNeeded + rowsNth) of
anyList
set end of newList to result

if columnNth is columnsNeeded then
set end of newList to return
else
set end of newList to tab
end if
end try
end repeat
end repeat

items 1 thru -2 of newList as string
end createFalseTable


set anyList to {"aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh"}

my createFalseTable(anyList, 2)
(*
returns
"aaa eee
bbb fff
ccc ggg
ddd hhh"
*)
my createFalseTable(anyList, 3)

(*
returns
"aaa eee bbb fff ccc ggg ddd hhh"

but should return
returns
"aaa ddd ggg
bbb eee hhh
ccc fff"
*)


  • Follow-Ups:
    • Re: Convert any list to a table?
      • From: "Bob.Kalbaugh" <email@hidden>
    • Re: Convert any list to a table?
      • From: Ric Phillips <email@hidden>
  • Prev by Date: Re: MultiAd Creator 6 - "color space" broken?
  • Next by Date: Re: MultiAd Creator 6 - "color space" broken?
  • Previous by thread: Re: Is beep a backdoor?
  • Next by thread: Re: Convert any list to a table?
  • Index(es):
    • Date
    • Thread