i’m VERY new to Applescript and am trying to build a simple application for use at work.
the following interface was built in interface builder. see that switch button that says “Digital Ad”?
Well, Upon entering all of the text fields and hitting the “Auto Create” button, my intent is to create a series of folders on a server with folder names based on the info entered in the text fields.
Here’s my problem:
if a user checks the “Digital Ads” box, upon hitting “Auto Create” i would like an extra folder to be created. However, i have so far been unable to figure a way to recognize whether the box is checked or unchecked, and then to specify what and when to do what i want to do (which is to create an extra folder).
Below is an abridged version of my verbose and inefficient script. Amy ideas or places to point me in the right direction?
p.s. ANY help would be appreciated. this forum so far seems to be a very valuable source of information! Thanks, Josh
global myJob, myDate, myCustomer, myFolder, myY, myz, mysupport, myworkup, myselection, mynewjob, mywidth, myheight, mysize, myDigital
on clicked theObject
if name of theObject is "thereset" then
tell window "Sherpa v1.0.5"
delete contents of text field "thejob" of tab view item "tabnew" of tab view "maintab"
delete contents of text field "thedate" of tab view item "tabnew" of tab view "maintab"
delete contents of text field "thecustomer" of tab view item "tabnew" of tab view "maintab"
end tell
else if name of theObject is "create" then
tell window "Sherpa v1.0.5"
try
set myJob to contents of text field "thejob" of tab view item "tabnew" of tab view "maintab" as string
set myDate to contents of text field "thedate" of tab view item "tabnew" of tab view "maintab" as string
set myCustomer to contents of text field "thecustomer" of tab view item "tabnew" of tab view "maintab" as string
set myFolder to contents of text field "thejob" of tab view item "tabnew" of tab view "maintab" & " " & contents of text field "thedate" of tab view item "tabnew" of tab view "maintab" & " " & contents of text field "thecustomer" of tab view item "tabnew" of tab view "maintab" as string
set myY to "SUPPORT"
set myz to "WORKUPS"
set mysupport to contents of text field "thejob" of tab view item "tabnew" of tab view "maintab" & " " & myY as string
set myworkup to contents of text field "thejob" of tab view item "tabnew" of tab view "maintab" & " " & myz as string
on error
display dialog "Sherpa has encountered an error."
end try
display dialog "Create job: " & myJob & " " & myDate & " " & myCustomer & " ?"
end tell
tell application "Finder"
activate
--compound if statements for june
if myDate is equal to "6-1" then
set myselection to "Ad_Server:*ADS:06 JUNE 04:01 JUN TUE" as string
else if myDate is equal to "6-2" then
set myselection to "Ad_Server:*ADS:06 JUNE 04:02 JUN WED" as string
–this compound IF statement continues and includes each date for the rest of the year…
else
display dialog "please enter date correctly. ex. 6-1 or 12-23."
end if
set mynewjob to myselection & ":" & myFolder as string
try
make new folder at myselection with properties {name:myFolder}
end try
try
make new folder at folder mynewjob with properties {name:mysupport}
make new folder at folder mynewjob with properties {name:myworkup}
open folder mynewjob
on error
display dialog "Error. Either there is no connection to the Ad Server or the job folder already exists."
end try
end tell
end if
end clicked
on should quit after last window closed theObject
return true
end should quit after last window closed