![]() |
Here's an AppleScript convertor to fix line ends in a saved document.
Code:
set tDoc to (choose file without invisibles) |
Further question:
Why doesn't something like this work? set foo to (read (choose file without invisibles)) set the clipboard to (do shell script "echo " & foo & " | tr \\r \\n") |
Quote:
Code:
set foo to (read (choose file without invisibles)) |
Thanks Mark, that does solve the problem of getting the shell script to work, but the result seems to be converted back by the system because when I check, the endings are still returns.
PS: I've been informed on another list, for the benefit of those who use Script Debugger 4 that there is a File menu pick to save with Unix endings. Would have saved a lot of grief. |
If I run your script from Post #41 on a plain text file, I get "Mac".
If I combine the two scripts I get "unix" Code:
set foo to (read (choose file without invisibles)) |
Quote:
From http://developer.apple.com/technotes/tn2002/tn2065.html Quote:
|
Quote:
|
Here's a new version of the above AppleScript for displaying Safari's memory usage. This version has the warnings (for exceeding the warn-level of memory usage) delayed longer each time you okay the warning dialog. This is useful in situations where Safari is exceeding the warning-level but you don't want to quit it immediately.
This version also has a property 'useDelayLoop' that you can set to make it possible to do test runs of the script from Script Editor. Code:
-- This AppleScript displays the amount of memory being used by Safari |
Runs nicely for me from either the Script Editor or Script Debugger 4. The fixLineEndings does it - bombproof!
|
New & improved! :)
Here's an improved version of the script. This version implements 'mark hunte's idea of showing CPU usage as well as memory usage. It shows Safari's CPU usage (in the title of the Safari window) whenever it exceeds 10% (I don't think having it give a warning dialog upon exceeding a certain CPU usage would be good since this script is intended to be left running all of the time, and sometimes you would expect Safari to be using a lot of CPU - e.g. when playing a Flash or Java game) This version might also be slightly more efficient (use less CPU) since it gets the process-id of the Safari process from System Events and then runs the 'ps' command only for that one process instead of getting info on all processes from 'ps' and filtering out all the rest. Code:
-- safariInfoInTitle: |
Works very nicely on MM, Hayne. With useDelayLoop set to true and the first handler set as:
Code:
on update() |
Thanks for testing this, NovaScotian.
By the way, if I add a line: updateAppInfo("firefox-bin", 150) then it does work fine as far as giving warnings about Firefox's memory usage (if it exceeds 150 MB with the above line). But as discussed in an earlier post, it doesn't show the memory usage in the title since Firefox is not AppleScriptable. |
There's a "hack" that makes it possible to get/set the name of a Foxfire window from Rob Griffiths in MacWorld.com. I haven't tried it for Foxfire (which I don't like) and don't particularly recommend it - I just point it out. I've used it successfully with Preview because it is useful to be able to manipulate its windows.
|
Thanks for reminding me about that hack to enable basic AppleScript support in apps that don't by default support AppleScript.
I haven't tried it yet with Firefox |
Here's a new version of the script with the following changes:
Here's the script: Code:
-- appInfoInTitle: |
Hayne,
Just like to say this app is very useful, Thanks |
Quote:
I still find it strange that sometimes this AppleScript application seems to take 10 or 15 MB of RAM and then if I quit it and re-launch it, its RAM usage is down to 5 MB. I'd be interested to hear if others are seeing this phenomenon. By the way, I edited the above (latest) version of the script to make it round the memory & CPU numbers to integers. It seemed silly to be reporting 1/10ths of MBs - and this saves a bit of space on the title-bar as well. |
My copy never seems to get below 14mb on my tower and PB.
I suppose I should be happy with it being consistent? :) thanks again. Mark |
[ot]
Speaking of "useful", Daniel Jalkut's Blog has some very flattering remarks, Hayne, for ash as a means of running AppleScripts via ssh when he's away from his machine. Looks neat. :)
|
Quote:
At one point I thought maybe it was somehow correlated with whether you had the script open in Script Editor or not. |
| All times are GMT -5. The time now is 01:42 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.