|
|
Clean Code
Inspired by Porkchop, I decided to see how clean I could get the code.
(Annoyingly, the site strips out multiple spaces, so you'll have to add them back to the 3rd paragraph get the formatting lined up again.)
set num to 10 set r to return do shell script "ls -l /var/vm/" set swp to ((number of paragraphs of result) - 1) do shell script "vm_stat" set vSS to result do shell script "ps auxmww" set appSS to paragraphs 2 through (num + 1) of result as list set d to r & "Swapfiles: " & swp & r set d to d & "Pageouts: " & vParse(vSS, 11) & r & r & r set d to d & "Free: " & vParse(vSS, 2) & r & r & r repeat with c in appSS set d to d & appParse(c) & r end repeat display dialog d & r on vParse(x, xn) set v to word -1 of (paragraph xn of x) set v to (v - (v mod 256)) / 256 as integer if v > 0 then set v to v & " MB" return v end vParse on appParse(x) set m to word 6 of x set m to (m - (m mod 1024)) / 1024 as integer if 10 > m then set m to " " & " " & m set AppleScript's text item delimiters to {"/"} set n to text item -1 of x set AppleScript's text item delimiters to {""} set o to offset of " -psn" in n if (o > 0) then set n to (text items 1 through (o - 1)) of n as string if n = "TruBlueEnvironment " then set n to "Classic" return m & " MB " & " " & n end appParse |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.09 seconds |
|