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

Re: Delimiting


  • Subject: Re: Delimiting
  • From: "Gary (Lists)" <email@hidden>
  • Date: Sat, 03 Sep 2005 12:57:27 -0400

"Robert Poland" wrote:

> Hi,
>
> I have a script that uses a <return> for
> delimiting. I use a repeat loop to extract data
> with two <return>s to separate blocks.
> The problem I'm having is how to reinsert the
> <return>s between lines of recovered data within
> the block. In the example below the return is
> ignored.
>
> set TheDescription to ""
> repeat with i from 3 to {iCount}
> set x to (myList's text item i)
> if x = "" then exit repeat
> if TheDescription = "" then
> set TheDescription to x
> else
> set TheDescription to
> TheDescription & ". " & (return) & x
> end if
> end repeat
> if TheDescription ‚ "" then set TheDescription to TheDescription & "."


-- --------------------------------------------------------
to split(needle, haystack) -- delim, string
    set oTIDs to the text item delimiters
    set the text item delimiters to needle
    set hay to (text items of haystack)
    set the text item delimiters to oTIDs
    return hay
end split
-- --------------------------------------------------------
to join(glue, chunks) -- delim, list
    set AppleScript's text item delimiters to glue
    set squished to ((text items of chunks) as string)
    set AppleScript's text item delimiters to {""}
    return squished
end join
-- --------------------------------------------------------


-- Version 1 -- Not using the above handlers.
--
set m to "mississippi"
set text item delimiters to {"i"}
set p to text items of m
set text item delimiters to {"a"}
set b to p as text
set text item delimiters to {"appa"}
set v to text items of b
set text item delimiters to {"ination"}
set e to v as text
set text item delimiters to {"m"}
set c to text items of e
set text item delimiters to {""}
set a to c as text


-- Version 2 -- With these handlers.
-- Long.
set m to "mississippi"
set p to split({"i"}, m)
set b to join({"a"}, p)
set v to split({"appa"}, b)
set e to join({"ination"}, v)
set c to split({"m"}, e)
set a to join({""}, c)


-- Version 2 -- With these handlers.
-- Short.
set m to "mississippi"
set a to join({""}, split({"m"}, join({"ination"}, split({"appa"},
join({"a"}, split({"i"}, m))))))



--
Gary

 _______________________________________________
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

References: 
 >Delimiting (From: Robert Poland <email@hidden>)

  • Prev by Date: Re: Delimiting
  • Next by Date: Re: still having trouble with SOAP
  • Previous by thread: Re: Delimiting
  • Next by thread: iTunes question
  • Index(es):
    • Date
    • Thread