• 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: list to a text representation of that list (followup)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: list to a text representation of that list (followup)


  • Subject: Re: list to a text representation of that list (followup)
  • From: Nigel Garvey <email@hidden>
  • Date: Thu, 17 Mar 2005 13:43:22 +0000

David C Andrews wrote on Wed, 16 Mar 2005 23:03:41 -0500:

>So, why doesn't this work?

>on try2() -- (your universal language code)
>	try
>		{{1, 2, 3}, "abc", pi, {"foo", 3, "bar"}, "z"} as integer
>	on error msg
>		set opening to offset of "{" in msg
>		set closing to offset of "}" in "" & (reverse of (characters of msg))
>		set list_string to text opening through -closing of msg
>	end try
>end try2
>
>try2() --> "{{1, 2, 3}, \"abc\", 3.14159265359, {\"foo\","

I've just got exactly the same result after accidentally leaving
AppleScript's text item delimiters set to "{". That would make "" &
(reverse of (characters of msg)) nearly twice as long as msg itself, with
the offset of "}" in it correspondingly increased.

Besides being horribly inefficient in its own right...

  offset of "}" in "" & (reverse of (characters of msg))
  --> list extraction, reversal, coercion & concatenation, 'offset'

... this method also has to ensure that the TIDs are set to ""
beforehand, which may mean restoring them to whatever they were
afterwards. That being the case, it makes sense to use the TIDs method
anyway to get the offsets.

  try
    {{1, 2, 3}, "abc", pi, {"foo", 3, "bar"}, "z"} as integer
  on error msg
    set astid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "{"
    set opening to (count msg's first text item) + 1
    set AppleScript's text item delimiters to "}"
    set closing to (count msg's last text item) + 1
    set AppleScript's text item delimiters to astid
    set list_string to text opening through -closing of msg
	 end try

NG
 _______________________________________________
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

  • Prev by Date: Re: tell a script to tend to system process for X amount of time?
  • Next by Date: Clipboard
  • Previous by thread: Re: list to a text representation of that list (followup)
  • Next by thread: [AS] Pages et GUIscripting
  • Index(es):
    • Date
    • Thread