2005-04-19

Path to Mac folders in UNIX (POSIX) form

A simple call to OSA from Terminal gets the UNIX paths common Mac locations.

$ osascript -e 'path to desktop'
alias Macintosh HD:Users:olegyk:Desktop:

$ osascript -e 'POSIX path of (path to desktop)'
/Users/user/Desktop/

$ osascript -e 'POSIX path of (path to fonts)'
/System/Library/Fonts/

$ osascript -e 'POSIX path of "LaCie"'
/Volumes/LaCie

2005-04-16

MacOSX.com - The Answer to Mac Support - [HOWTO] - Use iTunes as an alarm clock

MacOSX.com - [HOWTO] - Use iTunes as an alarm clock

Used UNIX cron to run AppleScript at specific times.

Simple and clean implementation. Complete explanation.

2005-04-10

Carbon: Error Message

In Carbon, most functions return error as OSStatus integer code. In all code I have seen so far, the programmer has to expect certain result codes and supply custom error messages to the user:


OSStatus err = Call(...);
if (err == errSomeError) {
Alert("This error occurred.");
}


I am looking for a way to generically obtain the system error message. Similar to how it is done on Windows.


The FormatMessage function can be used to obtain error message strings for the system error codes returned by GetLastError, as shown in the following sample code.



LPVOID lpMsgBuf;

FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf, 0, NULL );

MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );

2005-04-09

Test Again

This is a test posting.

Welcome to Blogger, a substantial collection of how-to and help documents to help you get more out of Blogger. Search through our collection with Article Search (to the right) or just browse through the categories below. If you can't find what you need here, send an email to the Blogger support team and we'll get back to you as soon as we can.

This page is powered by Blogger. Isn't yours?