AnsweredAssumed Answered

Expected end of line but found “"” When Opening/Editing a Script

Question asked by Slinky66 on Sep 10, 2012
Latest reply on Sep 12, 2012 by Slinky66

Title

Expected end of line but found “"” When Opening/Editing a Script

Post

     I am trying to edit a working AppleScript but when I try to save the changes, I get:

     Expected end of line but found “"”

     I took the script and dumped it into my AppleScript Editor and it compiles just fine and like I said, this script is running in a FM 10 database app just fine.

     So, I cancel out and reopen for editing and hit OK and even without changing anything, I get the same error:

     Expected end of line but found “"”


     The application was created in FileMaker 10 and I am trying to edit the script with FileMaker Pro Advanced 11, in case that matters.


     Not sure what to try next...


     Here is the complete script:


     -- Calculate_Inventory_Product_Count
     -- script "update inventory PO and Beginning Quantity"
     --this should only run out of the Inventory table

     set theDatabaseName to "F&B POs"
     set theCellName to "Product ID"
     --set theInventoryID to 18

     tell application "FileMaker Pro"
     set theInventoryID to contents of cell "ID" of current record -- must be an inventory record
     tell database theDatabaseName
     --get the intended previous inventory record
     show layout "Inventory - All Quantities"
     show every record
     set theStartDates to field "DateCounted" of table "Inventory"
     set theChosenStartDates to choose from list theStartDates with prompt "Choose a previous inventory date:"
     set theStartDate to item 1 of theChosenStartDates
     --get the id of the chosen inventory record
     show (every record of table "Inventory" whose cell "DateCounted" = theStartDate)
     copy cell "ID" of current record to thePriorID

     show (every record of table "Inventory" whose cell "ID" = theInventoryID)

     set cell "Previous Inventory Date" of current record to theStartDate
     copy cell "DateCounted" of current record to theEndDate

     show layout "Inventory Products"
     show (every record of table "Inventory Products" whose cell "Inventory ID" = theInventoryID)
     end tell

     set theProductIDs to field "Product ID"
     set ProductCount to the count of items in theProductIDs

     set ProductCount to the count of record of document theDatabaseName -- use found set

     tell document theDatabaseName -- use found set
     set totalQuantity to 0
     set totalMissed to 0
     set noPOfound to 0
     repeat with x from 1 to ProductCount
     --lookup the prior count for this product in the related record refered to by the inventory record
     --copy cell "Product ID" of record x of table "Inventory Products" to theCurrentProductID
     set theCurrentProductID to item x of theProductIDs
     try
     show layout "Inventory Products"
     show (every record of table "Inventory Products" whose cell "Inventory ID" = thePriorID and cell "Product ID" = theCurrentProductID as string)
     copy cell "Count" to thePriorTotal
     on error
     set thePriorTotal to 0
     set totalMissed to totalMissed + 1
     --display dialog ("Couldn't find " & theCurrentProductID as string) & " in inventory " & thePriorID as string
     set cell "marker" of record x of table "Inventory Products" to "*"
     end try

     try
     show (every record of table "Inventory Products" whose cell "Inventory ID" = theInventoryID and cell "Product ID" = theCurrentProductID as string)
     show layout "Inventory Products"
     set cell "Beginning Quantity" to thePriorTotal
     on error
     --why wouldn't it show up ???
     end try

     --lookup the PO quantity for this product in the given date range from the repeating fields
     show layout "Form View - 40"
     set theCellName to "Product ID"
     try -- find records one or more of whose repeating fields contains the Product ID
     show (records of table "Purchase Orders" whose cell theCellName is theCurrentProductID and cell "Ship Date" ≥ theStartDate and cell "Ship Date" ≤ theEndDate)
     set somethingFound to true
     on error
     set somethingFound to false
     end try

     set totalQuantity to 0
     if somethingFound then
     set theCount to count of records --in document theDatabaseName -- already in document

     repeat with y from 1 to theCount
     tell record y
     set theRepCount to count repetitions of cell theCellName
     repeat with j from 1 to theRepCount
     set theID to get data repetition j of cell theCellName
     if theID = theCurrentProductID then
     set totalQuantity to totalQuantity + (get data repetition j of cell "Product Quantity")
     end if
     end repeat
     end tell
     end repeat

     try
     show layout "Inventory Products" --record is still current?
     show (records of table "Inventory Products" whose cell "Inventory ID" = theInventoryID and cell "Product ID" = theCurrentProductID as string)
     set cell "PO Quantity" to totalQuantity
     on error
     set noPOfound to noPOfound + 1
     --display dialog theCurrentProductID as string
     end try

     end if

     --reset the "selection"
     show layout "Inventory Products"
     show (every record of table "Inventory Products" whose cell "Inventory ID" = theInventoryID)

     end repeat

     end tell

     end tell

     if totalMissed > 0 then
     display dialog ("Total item IDs not matched: " & totalMissed as string) & return & "No POs for item:" & noPOfound as string
     end if

fm-applescript-error.jpg

Outcomes