Re: Manipulating text
Re: Manipulating text
- Subject: Re: Manipulating text
- From: Jon Pugh <email@hidden>
- Date: Sat, 26 Sep 2009 07:56:53 -0700
[Reply directed to the list]
At 8:16 AM -0400 9/26/09, Doug Tallman wrote:
>I'm sure this is painfully obvious to some, but I'm not sure I see the reason ...
>
>why:
>
> copy "0123456789ABCDEF" to hConst
>
>and not
>
> set hConst to "0123456789ABCDEF"
>
>
>In other words, when do you use "copy" and when "set"
It'a not painfully obvious, in fact it's downright obtuse and has confused people since the dawn of AppleScript.
In this case, with literal data, they are the same. You can use either.
However, when using lists which can share data via references/pointers, set can share data, while copy always duplicates. In those sorts of situations, you need to use the one that makes sense.
I don't know why I used both here, other than random chance and the fact that it doesn't matter in this instance.
Other scripting languages use text for all data, while AppleScript uses many data types, including pointers as references, and as such it has more complex data management and handling than if it could only pass text around. This is, like most things, both good and bad.
The guy who wrote this part of AppleScript was bothered by the similarity and differences, but couldn't see any way to avoid it. Sometimes set and copy are the same, when data cannot be shared, and sometimes they're different, when data can be shared.
Most of the time it doesn't matter, unless it does. ;)
Jon
_______________________________________________
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