Jump to content
Server Maintenance This Week. ×

Script doesn't work in FMP, OK in Script Editor


This topic is 6178 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have a script that works great in Script Editor, but does not work in FMP natively. I have a repeat loop in the script. I have pasted the entire Applescript into just one FM Script step ("perform Applescript") and it does not work right. What it seems like is that the repeat loop does not do its repeat, it just goes through to the last value of the repeat. Inside of this repeat is another FM script that does a Find and then Sorts and goes to the last record found then.

Does FM handle doing script steps inside itself differently? Do they happen too fast? Does it ignore steps?

Also, does anyone have a suggestion how to save multiple variables into a list, like AS can? Can this be converted into a full FM script, or is it too complex?

Thanks for any help.

Chris

Here is the script:

set myLastBookList to {}

set myPrinterList to {"Printer1", "Printer2", "Printer3", "Printer4", "Printer5", "Printer6"}

display dialog "Make sure that all books have complete book-done information or this script will give false information."

tell application "FileMaker Pro"

--get fields from the main GigTracker

set myWeek to get field "BookPrintWeek" of current record of database "GigabyteTracker"

set myYear to get field "Year" of current record of database "Tracker"

tell database "BookRunPrinter_"

show database "BookRunPrinter_"

do script "shrink_window"

go to layout "Standard View"

set field "g_FindWeeks" to myWeek

set field "g_findDays" to myYear

repeat with i in myPrinterList

set field "g_FindPrinter" to i

try

do script "Find_YrWkPr_sort_last_sent"

--this script finds the books, and sorts them by last transmission time

end try

try

copy (get field "BookCode" of current record) to end of myLastBookList

--copy code to the list

end try

end repeat

go to layout "Finding_by_book_code"

--we MUST clear out all old find data or this won't work!

do script "Clear_All_Finds"

repeat with b in myLastBookList

set c to {(characters 1 thru 5 of : as string, (characters 6 thru 8 of : as string, ("20" & (characters 9 thru 10 of :)}

create request with data c

end repeat

find

end tell

end tell

Edited by Guest
Link to comment
Share on other sites

Without dissecting you AS, would I say keep the building of request native, because you otherwise needs to pause the AS'ing while the tiny native scripts are executed, otherwise will the AS continue with values not there yet.

I'm sorry to say that comprehensive scripting reveals a flat or flat'ish relational structure, and your scripting probably falls into this cathegory. The use of globals aren't pulling in the normalized direction either.

Try to make a list of the fields your tables consists of, an let us see if it can't be done without AS'ing. I usually save the AS'ing to inter applicational things going in or out of my solution, and not things which can be done natively - but try to justify your dispositions, nothing of whats occuring in your script seems originating from other applications.

--sd

Link to comment
Share on other sites

My operation here could be done in just one database, assuming a couple variables were filled in. I should have described more what it does.

I need to find for each of my printers, the last record of the week. So there will be 6 records found in the end, one for each "printer1,2,3,etc". I was trying to loop through to do the find request for a printer based on the printer name and week it printed, then sort those records by date, then save the unique identifier in my Applescript variable. Then repeat. Once I have all the unique identifiers, I can show only those records in the db by finding for each one.

Not sure how to save a found record's data in FM as a list, and I don't think I can 'mark' a record as found (I don't want to change the db to add fields just for this).

Link to comment
Share on other sites

My operation here could be done in just one database

You mean a single table - then lets do it in one table! This is one way it can be done, if we wont abide to you last clause - take a look at template 1...

and I don't think I can 'mark' a record as found (I don't want to change the db to add fields just for this).

Since it always are posible to make a new interface file, utilizing the separation model could you put you native scripting there as well as a customized TOG (table occurance group) ....Then would this be posible without adding extra fields - investigate template 2...

Admitted this was impossible before fm7, where you then have to let AS do the requests, if you weren't allowed to sneak in a summaryfield in the fields def.

Eventhough the number of record to aggregate over is pretty strained, is the method with the summary field better scalable.

--sd

test.zip

test2.zip

Link to comment
Share on other sites

This topic is 6178 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.