• 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: text 1 thru the result
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: text 1 thru the result


  • Subject: Re: text 1 thru the result
  • From: Axel Luttgens <email@hidden>
  • Date: Mon, 6 Dec 2010 18:06:28 +0100

Le 6 déc. 2010 à 15:54, Luther Fuller a écrit :

> I encountered a problem with this yesterday.
> Here's an example script ...
>
> property testString : "abcdefghijklmnopqrstuvwxyz"
>
> -- test 1
> set n to (-10 as integer)
> text 1 thru n of testString --> "abcdefghijklmnopq" correct
>
> -- test 2
> (10 as integer)
> text 1 thru -(the result) of testString --> "abcdefghijklmnopq" also correct
>
> -- test 3
> (-10 as integer)
> text 1 thru (the result) of testString --> error: Can't get 1 "abcdefghijklmnopqrstuvwxyz" thru -10 of text.
>
> It seems that if (the result) is used , then the minus sign must explicitly appear in the code.

Hello Luther,

I guess the role of an explicit minus sign is more a matter of evaluation precedence than anything else.


> This seems odd. Perhaps there is a bug here?

Could well be the case, as far as the range reference form is concerned; for example, result may appear without problem in an index reference form:

	property testString : "abcdefghijklmnopqrstuvwxyz"
	-10
	text result of testString --> "q"

One needs to somehow force the evaluation towards the wanted meaning; beside the minus sign, there's the always miraculous get:

	property testString : "abcdefghijklmnopqrstuvwxyz"
	-10
	text 1 through (get result) of testString --> "abcdefghijklmnopq"

Note that the phenomenon seems to occur with AppleScript properties; this one fails as above:

	property testString : "abcdefghijklmnopqrstuvwxyz"
	text 1 thru pi of teststring --> error: Can't get 1 "abcdefghijklmnopqrstuvwxyz" thru 3.14159265359 of text.
but may be "cured" the same way:

	property testString : "abcdefghijklmnopqrstuvwxyz"
	text 1 through (get pi) of testString --> "abc"

There must be a better way to characterize/isolate the problem, so as to submit a concise bug report.

Axel

 _______________________________________________
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

  • Follow-Ups:
    • Re: text 1 thru the result
      • From: Luther Fuller <email@hidden>
References: 
 >text 1 thru the result (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Given a POSIX Path...
  • Next by Date: Re: text 1 thru the result
  • Previous by thread: text 1 thru the result
  • Next by thread: Re: text 1 thru the result
  • Index(es):
    • Date
    • Thread