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

Re: text vs string


  • Subject: Re: text vs string
  • From: Pier Kuipers <email@hidden>
  • Date: Tue, 6 Feb 2001 09:32:28 +0000

I have noticed several examples of scripts with the data type "text" where I
would naturally have used "string". What is the difference between these
data types? I suspect that some of my frustration with strings in
AppleScript comes from utilizing them when I should be using data type
"text"

set textMessage to "Text to be displayed" as text
set stringMessage to "More Text to be displayed" as string
display dialog textMessage & return & stringMessage
--> displays both messages

-Michael Turner

The "Applescript Language Guide" which I had lying around somewhere has this to say on the subject:

"number" is a synonym for either "integer" or "real," "text" is a synonym for "string," and "styled text" is a synonym for a string that contains style and font information. You can coerce values using these synonyms, but the class of the resulting value is always the appropriate value class, not the synonym. Here are some examples:

set x to 1.5 as number
class of x
--result: real

set x to 4 as number
class of x
--result: integer

set x to "Hello" as text
class of x
--result: string

Does that clarify anything?

Pier.
--
Pier Kuipers
Visual ID
* the Media Asset Management solution *

2 Whitefriars
Aungier Street
Dublin 2
Tel. +353 1 476 7059
Mobile +353 87 294 3063
Fax +353 1 478 1366
ISDN +353 1 602 0754

http://www.visualid.com


References: 
 >text vs string (From: Michael Turner <email@hidden>)

  • Prev by Date: Re: text vs string
  • Next by Date: What the heck??!!!??
  • Previous by thread: text vs string
  • Next by thread: Re: text vs string
  • Index(es):
    • Date
    • Thread