• 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: Issue with AS variable in OS 10.2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue with AS variable in OS 10.2


  • Subject: Re: Issue with AS variable in OS 10.2
  • From: Paul Berkowitz <email@hidden>
  • Date: Thu, 24 Mar 2005 06:58:49 -0800

On 3/24/05 5:26 AM, "francois.houle" <email@hidden> wrote:

> I have a script that I originally setup in panther, but also wanted to have
> it work on 10.2. So since it basically was setting a variable to the result
> of a "do shell scrip", I thought it would be rather easy...
> So I modified the command and tested it in the Terminal... Works beautifully
> and gives me what I want as a result in the terminal... However, the moment
> I out it in the AS as following
>
> set the folder_size to do shell script "du -s /Volumes/servername | sed
> s'=/Volumes/servername=='"
> if folder_size is greater than 0 then
> blablabla
> end if
>
> When I attempt to run the script in 10.2.8 it automatically returns that the
> variable folder_size is not defined... It does compile properly and run
> properly in the terminal... Also works properly in Panther... Anyone have an
> idea why 10.2 doesn't ? Are there differences which I have not forseen
> betwen 10.2 and 10.3 when setting variables ? I can't see any in the
> dictionaries...

The only change to 'do shell script' listed in the AS 1.9.2 Release Notes
(always check <http://www.apple.com/applescript/releasenotes/>) is:

" The do shell script command now has an as parameter that specifies the
desired type of the result. The default is to return the result as UTF-8 if
possible. If the as parameter is not specified and the result is not valid
UTF-8, the result will be returned as typeText. [3080630] [3157877]
"
Although not perhaps strictly relevant it does raise the question "what type
is being returned?" No matter whether typeText or UTF=8, it's text of some
sort (probably plain text in AppleScript). But your next line

    if folder_size is greater than 0 then

is treating it as if it's a number. So how about

    set the folder_size to (do shell script "du -s /Volumes/servername | sed
 s'=/Volumes/servername=='") as number -- or real (or integer?)

?

Another check of the Release Notes shows


"
 Real numbers can now be coerced to integers even if they have a non-zero
fractional part. Rounding is used to do the coercion. [2849518]
"

which I don't suppose applies here, but there may be some other fix
concerning coercion from text types to numbers when using math operators.

--
Paul Berkowitz


 _______________________________________________
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

References: 
 >Issue with AS variable in OS 10.2 (From: "francois.houle" <email@hidden>)

  • Prev by Date: Issue with AS variable in OS 10.2
  • Next by Date: Re: Issue with AS variable in OS 10.2
  • Previous by thread: Issue with AS variable in OS 10.2
  • Next by thread: Re: Issue with AS variable in OS 10.2
  • Index(es):
    • Date
    • Thread