property debug : 0 -- 1 is on, every other integer is off property loc : "dummy" --dummy value to pass when debug is off --first, check to make sure the plist file exists; construct the path first set plistFile to ((path to preferences folder from user domain) as string) & "com.yahoo.groups.tech.wordperfectmac.openwpfiles.plist" tell application "System Events" exists file plistFile if the result is false then if debug = 1 then set loc to "The plist file does not exist." end if my setDataFolder(loc) -- no plist, so figure out the UNIX folder else -- there's a plist, so check for the value of the UNIXFolderPath set anError to false -- set up a reminder to prevent us from re-entering later try set UNIXFolderPath to value of property list item "UNIXFolderPath" of property list file plistFile on error --if there's an error getting the value, just figure out the UNIX folder again (this is probably the first run and the value hasn't yet been set initially) if debug = 1 then set loc to "The UNIXFolderPath plist key does not exist." end if set anError to true --we don't want to figure out the UNIX folder path and then re-enter here, so we call setDataFolder later, inside another if-statement end try if anError is false then -- only check to see if UNIXFolderPath is a valid folder if we actually retrieved something from the plist exists folder UNIXFolderPath if the result is false then if debug = 1 then set loc to "The UNIXFolderPath is not a valid folder." end if my setDataFolder(loc) -- The supposed UNIX folder doesn't exist else -- we have a live UNIX folder; let's open files if debug = 1 then display dialog "Success! There's a valid UNIX folder ready for use. Let's go sheep-shaving!" end if end if else -- (anError = true) we didn't retrieve a value for UNIXFolderPath from the plist my setDataFolder(loc) end if end if end tell on setDataFolder(loc) if debug = 1 then display dialog loc & " We need a UNIX folder before we can go sheep-shaving!" end if -- do all the stuff to determine the UNIX folder from the .sheepshaver_prefs file -- and store the path as, e.g., myNewUNIXFolderPath -- finally, write the UNIX folder to the prefs so we'll have it from here on out do shell script "defaults write com.yahoo.groups.tech.wordperfectmac.openwpfiles UNIXFolderPath -string " & myNewUNIXFolderPath end setDataFolder