1 property bochs_path :
"Contents/MacOS/bochs"
2 property bochs_app :
""
5 tell application "Finder" to get container
of (
path to me)
as string
6 set script_path
to POSIX
path of result
9 set bochs_alias
to findBochs()
11 -- Tell Terminal to run bochs from the command line
12 --Use the script's directory as the current directory
13 tell application "Terminal"
15 do
script "cd '" & script_path &
"';exec '" & (POSIX
path of bochs_app) & bochs_path&
"'"
16 -- Wait for Terminal to change the name first, then change it to ours
18 set AppleScript's
text item delimiters
to "/"
19 set the text_item_list
to every text item of the script_path
20 set AppleScript's
text item delimiters
to ""
23 set next_to_last
to ((
count of text_item_list) -
1)
24 set the folder_name
to item next_to_last
of text_item_list
25 set name of front
window to "Running bochs in ../" & folder_name &
"/"
29 -- Taken from examples at http://www.applescriptsourcebook.com/tips/findlibrary.html
30 to Hunt
for itemName
at folderList
31 --Returns path to itemName as string, or empty string if not found
32 repeat with aFolder
in folderList
34 if class of aFolder
is constant
then
35 return alias ((
path to aFolder
as string) & itemName)
as string
36 else if folder of (info
for alias aFolder)
then
37 return alias (aFolder & itemName)
as string
39 on error number -
43 --item not there, go to next folder
42 return "" --return empty string if item not found
47 if bochs_app
is "" then error number -
43
48 return alias bochs_app
50 -- bochs_app no good, go hunting
52 tell application "Finder" to get container
of (
path to me)
as string
53 set this_dir_alias
to alias result
54 tell application "Finder" to get container
of (this_dir_alias)
as string
55 set one_up_dir_alias
to alias result
56 set TheUsualPlaces
to {this_dir_alias
as string, one_up_dir_alias
as string}
57 Hunt
for "bochs.app" at TheUsualPlaces
58 set result_alias
to result
59 if result_alias
is "" then error number -
43
60 set bochs_app
to result_alias
as string
63 --Give up seeking, Ask the user
64 choose application with prompt
"Please locate Bochs:" as alias
65 set result_alias
to result
66 set bochs_app
to result_alias
as string