FileMaker Scripts Won't Compile
FileMaker Scripts Won't Compile
- Subject: FileMaker Scripts Won't Compile
- From: Eric Schult <email@hidden>
- Date: Wed, 10 Jan 2001 16:35:55 -0600
I'm having trouble with a set of Applescripts I'm trying to run from within
Filemaker Pro 5's Scripts menu.
The scripts compile fine and run fine from within Script Editor, but when I
copy the script into the "Specify Applescript" text window in FMP's
ScriptMaker and hit "Okay", I get compile errors (i.e. "Expected end of
line, etc., but found property", or "Stack overflow", depending on the
script.)
I have half a dozen or more other scripts that work fine from within the
same FMP database. These problem scripts are not any longer or more complex
than those that do work. I'm wondering whether my use of specific Osaxen in
these scripts could be my problem. I don't use Tanaka's Osax in the other
scripts that do work, but use the WriteToFile and AppendToFile commands in
Tanaka's in the problem scripts.
What follows is the script that produces the "Stack overflow" error. Any
thoughts?
WES
(* WRITE THE JT ADTRACKER DATABASE TO AN HTML REPORT. *)
property htmlFolder : "JT AdTracker:~HTML:" -- path to new html file
property pdfOutFolder : "JT AdTracker:~PDFs:Out:" -- path to Distiller's
"Out" folder
(* IF PATH TO HTML REPORTS DOESN'T EXIST, PROMPT USER TO SPECIFY. *)
tell application "Finder"
if (exists (item htmlFolder)) true then
set htmlFolder to (choose folder with prompt "Where do you want so
save your HTML report?") as string
end if
end tell
tell application "Finder"
if (exists (item pdfOutFolder)) true then
set pdfOutFolder to (choose folder with prompt "Where is
Distiller's \"PDF:Out:\" folder?") as string
end if
end tell
(* ALLOW USER TO CHANGE THE PATH TO THE HTML REPORTS. *)
if (keys pressed) = {"Option"} then
set htmlFolder to (choose folder with prompt "Where do you want so save
your HTML report?") as string
set pdfOutFolder to (choose folder with prompt "Where is Distiller's
\"PDF:Out:\" folder?") as string
end if
(* DO APPROPRIATE ERROR HANDLING. *)
tell application "FileMaker Pro"
tell database 1
try
set htmlTitle to "JT AdTracker: " & (cell "Run Date" of record
1)
on error
display dialog "The database \"" & name of document 1 & ,
"\" doesn't have any records with the required cell \"Run
Date\"." buttons {"Cancel"} with icon stop
end try
set runDate to (cell "Run Date" of record 1)
end tell
tell database 1
try
show (every record whose cell "Ad Number" "")
on error
display dialog "The database \"" & name of document 1 & ,
"\" doesn't have any records with data in the cell \"Ad
Number\"." buttons {"Cancel"} with icon stop
end try
end tell
(* EXTRACT DATA FOR TOP OF HTML PRODUCTION REPORT (i.e. number of ads,
how many done, how many not, etc.). *)
tell document 1
set adCount to count of records
try
show (every record whose ((cell "Status" = "Ad EPSed") or (cell
"Status" = "Neg Ready")))
set doneCount to count of records
on error
set doneCount to 0
end try
end tell
tell database 1
show (every record whose cell "Ad Number" "")
end tell
tell document 1
try
show (every record whose ((cell "Status" "Ad EPSed") and (cell
"Status" "Neg Ready")))
set outstandingCount to count of records
on error
set outstandingCount to 0
end try
end tell
set donePercent to round ((doneCount / adCount) * 100)
end tell
(* WRITE HEADER INFORMATION TO HTML FILE. *)
tell application "Finder"
activate
if (exists (folder (htmlFolder & runDate & ":" as string))) = false then
-- dated HTML sub-folder must be created
make new folder at folder htmlFolder
repeat until (exists (folder (htmlFolder & "untitled folder" as
string))) = true
delay 5
end repeat
select folder (htmlFolder & "untitled folder" as string)
set name of selection to runDate
end if
end tell
writeToFile ("<html>" & return & "<head>" & return & "<title>" & htmlTitle &
"</title>" & return & ,
"</head>" & return & "<body bgcolor=\"#FFFFFF\">" & return & "<center>"
& return & "<p>" & return & ,
"<img SRC=\"../jtadtracker.jpg\" BORDER=0 height=38
width=213></p></center>" & return & "<center>" & ,
return & "<p>" & return & runDate & "
o Updated " & ,
(current date) as string) & "</p></center>" & return & return &
"<center>" & return & ,
"<p>" & return & "Total Ad Count - " & adCount & "
o Ads Ready - " & ,
doneCount & " o Ads Outstanding - "
& outstandingCount & ,
" o Percentage Complete - " & donePercent
& "%" & return & ,
"</p></center>" & return & return & "<table BORDER=3 CELLSPACING=3
CELLPADDING=3 >" & ,
return to file (htmlFolder & runDate & ":" & "ad_status.html") creator
"MOSS" type "TEXT" -- html formatting
appendToFile "<tr>" & return & "<td>" & return & "<center><b>Ad
Number</b></center>" & return & ,
"</td>" & return & return & "<td>" & return & "<center><b>Columns x
Inches</b></center>" & return & ,
"</td>" & return & return & "<td>" & return &
"<center><b>Account</b></center>" & return & ,
"</td>" & return & return & "<td>" & return &
"<center><b>Description</b></center>" & return & ,
"</td>" & return & return & "<td>" & return &
"<center><b>Section</b></center>" & return & ,
"</td>" & return & return & "<td>" & return &
"<center><b>Color</b></center>" & return & ,
"</td>" & return & return & "<td>" & return &
"<center><b>Salesperson</b></center>" & return & ,
"</td>" & return & return & "<td>" & return &
"<center><b>Pickup</b></center>" & return & ,
"</td>" & return & return & "<td>" & return & "<center><b>Next
Run</b></center>" & return & ,
"</td>" & return & return & "<td>" & return &
"<center><b>Status</b></center>" & return & ,
"</td>" & return & return & "<td>" & return &
"<center><b>Artist</b></center>" & return & ,
"</td>" & return & return & "<td>" & return & "<center><b>On
Page</b></center>" & return & ,
"</tr>" & return & return to file (htmlFolder & runDate & ":" &
"ad_status.html") -- html table header formatting
(* WRITE DATA FROM JT ADTRACKER DATABASE TO HTML FILE. *)
tell application "FileMaker Pro"
tell database 1
show (every record whose cell "Ad Number" "")
sort document 1 by field "Ad Number" in order ascending
end tell
tell document 1
repeat with i from 1 to count of records
set adNumber to cell "Ad Number" of record i
set colWidth to cell "Column Width" of record i
set inchDepth to cell "Depth" of record i
set acctName to cell "Account Name" of record i
set adDescription to cell "Ad Description" of record i
set sectionRequest to cell "Section Request" of record i
set adColor to cell "Color" of record i
set salespersonName to cell "Salesperson Name" of record i
set pickupDate to cell "Pickup" of record i
set nextRunDate to cell "Next Run" of record i
set adStatus to cell "Status" of record i
set theArtist to cell "Artist" of record i
set onPage to cell "On Page" of record i
if inchDepth = "" then
set inchDepth to "0\""
end if
if acctName = "" then
set acctName to "?"
end if
if adDescription = "" then
set adDescription to "?"
end if
if sectionRequest = "" then
set sectionRequest to "?"
end if
if adColor = "" then
set adColor to "?"
end if
if salespersonName = "" then
set salespersonName to "?"
end if
if ((pickupDate = "") or (pickupDate = "0")) then
set pickupDate to "-"
end if
if ((nextRunDate = "") or (nextRunDate = "0")) then
set nextRunDate to "-"
end if
if adStatus = "" then
set adStatus to "?"
end if
if theArtist = "" then
set theArtist to "-"
end if
if onPage = "" then
set onPage to "-"
end if
if ((adStatus = "Ad EPSed") or (adStatus = "Output to Neg") or
(adStatus = "Not Scheduled!")) then
tell application "Finder"
if (count of (items in folder pdfOutFolder whose (name =
(adNumber & ".pdf" as string)) and ,
((file type = "PDF ")))) = 1 then -- the PDF is in
"PDFs:Out:"
set adNumber to "<A HREF=\"../../~PDFs/Out/" &
(adNumber & ".pdf" as string) & "\">" & ,
(adNumber & ".pdf" as string) & "</A>" -- make a
link in the HTML report to an existing PDF of the ad
end if
end tell
end if
appendToFile "<tr>" & return & "<td>" & adNumber & "</td>" &
return & return & ,
"<td>" & "<center>" & (colWidth as integer) & " x " &
inchDepth & "</center>" & ,
"</td>" & return & return & "<td>" & acctName & "</td>" &
return & return & "<td>" & ,
adDescription & "</td>" & return & return & "<td>" &
sectionRequest & "</td>" & ,
return & return & "<td>" & adColor & "</td>" & return &
return & "<td>" & ,
salespersonName & "</td>" & return & return & "<td>" &
"<center>" & pickupDate & ,
"</center>" & "</td>" & "<td>" & "<center>" & nextRunDate &
"</center>" & "</td>" & "<td>" & ,
"<center>" & adStatus & "</center>" & "</td>" & return &
return & "<td>" & "<center>" & ,
theArtist & "</center>" & "</td>" & return & return & "<td>"
& onPage & "</td>" & ,
return & return & "</tr>" & return & return to file
(htmlFolder & runDate & ,
":" & "ad_status.html") -- data from JT AdTracker as html
end repeat
end tell
end tell
(* WRITE END OF TABLE AND END OF FILE TAGS TO HTML FILE. *)
appendToFile "</table>" & return & return & "<br> " & return &
"</body>" & ,
return & "</html>" & return to file (htmlFolder & runDate & ":" &
"ad_status.html") -- end of table & end of html file tags
beep 2