Ok, initial project worked ok. I"m modifying the script to get rid of a display dialog box. that set the result to one of two buttons. I’m trying to use a pop up button. It has two choices, X or Y. In my script this is what chooses what to do. Am i just missing it when i think that setting the result to the name of the variable in the AS menu under the inspector’s last window should define the variable? I’m getting an error right away saying that the below variable is not defined.
on choose menu item theObject
set result to ScriptChoice
end choose menu item
-- AFV Multimedia.applescript
-- AFV Multimedia
-- Created by Brock Benjamin on 8/24/09.
-- Copyright 2009 __MyCompanyName__. All rights reserved.
global ScriptChoice
global CaseNumber
set ScriptChoice to missing value
set CaseNumber to missing value
on end editing theObject
set result to CaseNumber
end end editing
on choose menu item theObject
set result to ScriptChoice
end choose menu item
on clicked theObject
--combined AFV Multimedia
--display dialog "911 or pictures" buttons {"911", "Pictures"} default button 1 with icon note
--set mediaReturned to result
set mediaReturned to ScriptChoice
log mediaReturned
if true then
-- gets case number and returns it as a record and then converts it to text
--display dialog "What is the Case number? (Please enter without hyphen)" default answer "" buttons {"F2-Go..."} default button 1
--set caseId to (text returned of result) as text
set caseId to CaseNumber
log caseId
-- remove hyphen if it was included
if third character of caseId is equal to "-" then
set cutYear to text 1 thru 2 of caseId
set cutCase to text 4 thru 9 of caseId
set caseId to cutYear & cutCase as string
end if
log caseId
-- searches for the audio file
set thefolder to "Recordings$"
set thefolder to quoted form of POSIX path of thefolder
tell application "Finder"
set theFiles to (do shell script "find " & thefolder & " -type f -name " & caseId & "*.*")
set foundFiles to 0
log foundFiles
set foundFiles to every paragraph of theFiles
log foundFiles
log theFiles
set countCharacter to count of (characters of theFiles as text)
log countCharacter
if countCharacter is less than 3 then
display dialog "There are no files!" buttons {"Cancel Search"} default button 1 with icon stop
end if
-- sets all files found to HFS file names
repeat with i from 1 to number of items in foundFiles
set item i of foundFiles to (item i of foundFiles as POSIX file)
end repeat
-- Shows files in finder window
activate
reveal foundFiles
end tell
display dialog "Do you want to cancel search and view files or make a CD?" buttons {"Cancel Search", "Cd"} with icon caution
-- make a playlist
tell application "iTunes"
if not (exists playlist "caseId") then make new playlist with properties {name:"caseId"}
tell playlist "caseId"
set this_list to {foundFiles}
add this_list to it
set dbid to tracks's database ID
--delete--Once you've finished recording or whatever, enable this to be done with the playlist
end tell
activate
set view of front browser window to playlist "caseId"
end tell
--burn cd with itunes current settings using GUI
--display alert "Is iTunes set to burn audio CDs?" buttons {"Cancel", "Ok"} default button 2 giving up after 25
tell application "System Events"
set foremost to true
tell process "iTunes"
click button "Burn Disc" of window "iTunes"
repeat until exists window "Burn Settings"
delay 0.5
end repeat
click radio button "Audio CD" of window "Burn Settings"
delay 1
click button "Burn" of window "Burn Settings"
end tell
end tell
-- waits for CD to mount on desktop
tell application "Finder"
activate
if exists disk "caseId" then
display dialog "Finished?"
else
repeat until (list disks) contains "caseId"
delay 25
end repeat
end if
display alert "CD Done" buttons {"Done"} default button 1
end tell
else
-- gets case number and returns it as a record and then converts it to text
display dialog "What is the Case number? (Please enter with hyphen)" default answer "" buttons {"F2-Go..."} default button 1
set caseId to (text returned of result) as text
log caseId
--determines what file to search based upon two digit year.
set caseYear to text 1 thru 2 of caseId
log caseYear as string
if caseYear is equal to "07" then
set searchFolder to "CrimeScene$:2007 crime Photos:"
else if caseYear is equal to "08" then
set searchFolder to "CrimeScene$:2008 Crime Photos:"
else if caseYear is equal to "09" then
set searchFolder to "CrimeScene$:2009 Crime Photos:"
else if caseYear is equal to "10" then
set searchFolder to "CrimeScene$:2010 Crime Photos:"
end if
log searchFolder
-- searches for and discrimes the picture files.
set baseFolder to quoted form of POSIX path of (searchFolder)
log baseFolder
set foundFolders to do shell script "/usr/bin/find " & baseFolder & " -type d -name " & caseId & "*"
repeat with oneFolder in (get paragraphs of foundFolders)
tell application "Finder" to open folder (POSIX file (contents of oneFolder) as text)
end repeat
set countCharacter to count of (characters of foundFolders as text)
log countCharacter
if countCharacter is less than 3 then
display dialog "There are no files" buttons {"Cancel Search"} default button 1 with icon stop
end if
--set activated window to coverflow and select the first JPEG image
tell application "Finder"
get name of Finder window 1
set winRef to Finder window 1
select winRef
set bounds of winRef to {1719, 42, 2559, 594}
set sort direction of column id name column of list view options of winRef to normal
set current view of winRef to flow view
select (first item of winRef whose kind is "JPEG image")
end tell
end if
end clicked
Browser: Safari 528.17
Operating System: Mac OS X (10.5)