osx

Mac Open Source - the Fink command

Recently I started using Fink on Mac OS X to install Unix open source software. Fink is easy to use, and simplifies the process of installing open source software applications on Mac OS X.

To learn about how to use Fink, just open a Terminal window and type this command:

fink --help

That brings up the following help text (the fink man page):

Copy files on Mac OS X using drag-and-drop

Mac drag and drop FAQ: How do I copy files on a Mac OS X system using drag and drop between one or more Mac Finder windows?

It turns out that when you drag and drop a file between two Finder windows on the same Mac OS X filesystem you end up moving the file. Unfortunately that's not usually what I want to do; usually I want to copy the file, which recently begged the question "How do I copy files when using drag and drop?"

How to run an AppleScript from the Mac OS X Unix shell

AppleScript FAQ: How can I run an AppleScript script from the Mac Unix terminal (Unix command line)?

A cool thing about Mac OS X is that you can run AppleScript programs from the Unix shell. (Well, I guess it's cool if you're a Unix user.)

Running an AppleScript program from the Unix shell turns out to be surprising easy. For instance, if my current working directory has a script named OpenUrls.scpt in it, I can run that script from the command line like this:

How to customize AppleScript dialogs (dialog boxes)

AppleScript FAQ: How can I customize AppleScript dialog boxes?

When you display an AppleScript dialog box with the display dialog code, you don't have to just use the standard Cancel and OK buttons, you can change the text to something more meaningful to your specific prompt. For instance, suppose you want to ask someone their age range:

display dialog "How old are you?" buttons {"Less than 1", "Older than 1"}

(Okay, not the greatest example in the world, but that's all I've got today.)

AppleScript repeat while examples

AppleScript while loop FAQ: Can you share some examples of the AppleScript while loop syntax (the AppleScript repeat while syntax)?

Instead of using a keyword like "while" to create loops, AppleScript uses the "repeat" keyword to create loops. There are several versions of this syntax, as follows.

AppleScript repeat syntax: Repeat X times

Here's how to repeat an AppleScript command X number of times:

AppleScript: How to display a number in a dialog

To display a number in a dialog using AppleScript, just treat it like a string and you'll be fine. Here's a direct example:

display dialog 4.79

And here's an example using a variable:

set myNum to 4.88
display dialog myNum

macOS AppleScript example: Display clipboard contents in a dialog

AppleScript clipboard FAQ: Can you demonstrate an AppleScript clipboard example, such as displaying the Mac OS X clipboard contents in an AppleScript dialog?

One of the crazy things about AppleScript is how easy it is to get the contents of the clipboard, and then display them in a dialog. Here's an AppleScript clipboard dialog example that does just that:

display dialog (the clipboard)

Yep, that's it, just one line of text. Put this AppleScript code in your own ScriptEditor and run it, and you'll see it display the clipboard contents.

An AppleScript dialog textfield example

AppleScript dialog FAQ: How can I display an AppleScript dialog with a textfield (text field)?

A frequent AppleScript question is "How do I prompt a user to enter some text?" Here's how you display an AppleScript dialog to prompt a user to enter a simple piece of information, in this case their name:

display dialog "What is your name?" default answer ""

Running this AppleScript dialog code results in the following dialog: