• 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: How do I delete the 1st three characters from a variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I delete the 1st three characters from a variable


  • Subject: Re: How do I delete the 1st three characters from a variable
  • From: Matt Deatherage <email@hidden>
  • Date: Tue, 3 Jan 2006 16:57:28 -0600

On 1/3/06 at 2:43 PM, Dave Balderstone <email@hidden>
wrote:

> set mynewimagename to characters 4 through -1 of myimage

Point of order: on every system I tried, this sets mynewimagename to a
*list* of every character intended.  You have to coerce it to make it
work:

> set mynewimagename to (characters 4 through -1 of myimage) as text

It works in Mark Reed's example because he already typed the new
variable as text before appending the characters:

> set mynewimagename to "ENG" & characters 4 through end of myimage

Appending a list to a string gives you a string, even if the result
doesn't make much sense:

> return "test" & {-4, 15.7, "Horace"}
< "test-415.7Horace"

Second point of order: as Mark Reed showed out, you don't *need* to use
the semi-hidden fact that negatively-numbered characters of a string
start counting from the end instead of the beginning (so character -2
is the next-to-last character, and so on).  You can do this with
AppleScript's English-like syntax:

> set mynewimagename to (character 4 through last character) of myimage as text

..although I should note that AppleScript's tokenizer compiles and
returns the parenthesized expression as "(characters 4 through -1)"
anyway.  The former is just easier to read, IMHO.

The following also work, don't change upon compiling, and are clearer to read (also IMHO):

> set mynewimagename to text 4 through end of myImageName --Mark Lively
> set mynewimagename to (characters 4 through end of myImageName) as text

--Matt
--
Matt Deatherage                              <email@hidden>
GCSF, Incorporated                      <http://www.macjournals.com>

"Wanting to meet an author because you like his work is like wanting
 to meet a duck because you like pâté."
   -- Margaret Atwood


 _______________________________________________
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

  • Follow-Ups:
    • Re: How do I delete the 1st three characters from a variable
      • From: Dave Balderstone <email@hidden>
    • Re: How do I delete the 1st three characters from a variable
      • From: Shane Stanley <email@hidden>
References: 
 >Re: How do I delete the 1st three characters from a variable (From: Dave Balderstone <email@hidden>)

  • Prev by Date: [InDesign CS/XML] Find/Replace via tags
  • Next by Date: Re: How do I delete the 1st three characters from a variable
  • Previous by thread: Re: How do I delete the 1st three characters from a variable
  • Next by thread: Re: How do I delete the 1st three characters from a variable
  • Index(es):
    • Date
    • Thread