sometimes it helps to cleanup certain project directories and force a clean rebuild. This function is not built into Objective Basic, so I wrote my own version with a little help from AppleScript.
In order to have the script available while working with ObjectiveBasic, you have to activate the AppleScript Menu from ScriptEditor which you find in the "Utilities" subfolder of "Applications". You choose "Preferences..." and select "Show Script Menu in Menu Bar". After that an ancient scroll should appear in the menu bar. Depending on the application you are working with you get specific scripts for this application.
Save the script into ~/Library/Scripts/Applications/Objective-Basic as cleanCurrentProject.scpt and you should be done. After that you should see cleanCurrentProject as an item in the script drop down. Select it and it will move certain files into the trash bin.
- Code: Select all
-- cleanCurrentProject.scpt by U. Killermann
-- use at your own risk, no warranty - it works for me
--
on getOBProject()
-- first we obtain the current working directory for Objective Basic
set obProjectPath to (path to current user folder as string) & "Library:Objective-Basic:LastProject.txt"
set projectHandle to open for access file obProjectPath
-- the read will fail if LastProject.txt isn't present, so we'll have
-- to cover this situation
--
try
set theProjectDir to read projectHandle
on error
display alert "Oops" message "Objective Basic's last project can't be found!"
return
end try
return theProjectDir
-- if we are here we should have the project's main directory at hand
-- since OB projects are all structured the same way, we can proceed
end getOBProject
on Posix2AS(posixPath)
set ascriptPath to POSIX file posixPath
tell application "Finder"
set theFolder to folder ascriptPath
end tell
return (theFolder as string)
end Posix2AS
on clearPosixDirectory(thePosixPath)
set theASFolder to Posix2AS(thePosixPath)
clearDirectory(theASFolder)
end clearPosixDirectory
on clearDirectory(thePath)
tell application "Finder"
set theDirectory to folder thePath
delete files of theDirectory
end tell
end clearDirectory
-- let the user decide if she want to clear the current project
set answer to display dialog "Clear current project?" buttons {"no", "yes"}
if (button returned of answer) is "no" then return
set currentProject to getOBProject()
-- isolate the project's name
set text item delimiters to "/"
set projectName to (last item of text items of currentProject)
set appName to projectName & ".app"
set executablePath to "/" & appName & "/Contents/MacOS"
set theSubDirectories to {"/ObjC/Release", "/Build/Release/o", "/Build/Release/ObjB", "/Build/Release/Objc", executablePath}
-- now do it!
repeat with theSubDirectory in theSubDirectories
clearPosixDirectory(currentProject & theSubDirectory)
end repeat
If you append
- Code: Select all
tell application "Finder"
empty trash
end tell
even the trash will be emptied automatically.
Kind regards
Udo