Re: Applescript in a Nutshell
Re: Applescript in a Nutshell
- Subject: Re: Applescript in a Nutshell
- From: Mr Tea <email@hidden>
- Date: Thu, 07 Nov 2002 09:31:06 +0000
This from Joey Parshley - dated 071102 12.26 am:
>
I am reading this book and tried out the first script. I compiled in OS
>
9 but did not in Jaguar can someone tell me why?
>
>
Here is the script
>
tell application "Finder"
>
activate
>
set memblock to (largest free block / 1024 / 1024)
>
display dialog "The largest free block is about " & (memblock) &,
>
" megabytes."
>
end tell
>
>
When I try to check the syntax I get the following syntax error and the
>
word "free" in the parentheses is highlighted.
>
>
"Expected ',' but found identifier."
>
>
Does applescripting not carry over into Jaguar? What should I be
>
looking at to decipher the error statement? I tried the dictionary for
>
Finder and thought I might see something about "free" but no dice.
Yes, Joey, Applescripting does carry over into Jaguar, but some aspects of
the system have changed beyond recognition, and scripts that accessed
functions that are obsolete in OS X will break.
Memory management in X is radically different to the OS 9 way, so the
'largest free block' info that was previously found in the 'about this
mac/computer' window no longer exists. 'Virtual' memory is compulsory, its
upper limit constrained only by the amount of storage space on your startup
disk, and data held in 'real' RAM that isn't actually in use (ie, the
process that put it there is idling in the background) is routinely shunted
into swap files on your hard drive. In these transitional times, confusion
can arise because parts of OS X are littered with vestigial leftovers - for
example, 'total partition size' and 'partition space used' are still listed
as properties of running processes, even though the values returned are
meaningless.
If you need to find out info about memory use, you can check it with the
Process Viewer utility, but that's not scriptable (yet). And there may be
some arcane means of getting this sort of info via the Terminal (OS X's
window into its Unix underpinnings) but I don't know diddly-squat about
that.
Alternatively, if you just want to confirm that scripting is possible in X,
try this variation of the script you posted:
tell application "Finder"
activate
set memblock to round ((free space of startup disk) / 1024 / 1024)
display dialog "The startup disk contains about " & (memblock) & "
megabytes of free space."
end tell
(Any lines of the script that abut the left edge of your email message
window and do not begin with 'tell' or 'end' have been wrapped. You will
need to restore them to the end of the previous line for the script to
compile.)
Cordially
Mr Tea
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.