August 24, 20169 yr I am trying to open my (local) FM 14 Pro file [which has an auto-exec "Import Script"] but the script needs a variable file name. How do I pass this variable file name into Filemaker at 1) the time of the file open or 2) at the time of running the script (if I switch to manual execution)? Is #1 by using the fmp:// syntax from a web browser external to FM? (or is that syntax just for use when invoked from INSIDE a FM file?) Edited August 24, 20169 yr by fm8443
August 24, 20169 yr How is this file name variable? Does it change each time you open the file? Is it in a known location, but the name changes?
August 24, 20169 yr Author It's an Excel file in a folder. File name and folder name may change each time. Always known by me. (To be clear - I may not have the import script auto-execute if I can't do #1. I may just run the script manually if I can do #2 - however I want to operate this either way with a macro program (looping through different files in known locations).)
August 24, 20169 yr Well, you can _not_ specify a location, and you should get a prompt asking for the file.
August 24, 20169 yr 3 hours ago, fm8443 said: I am trying to open my (local) FM 14 Pro file [which has an auto-exec "Import Script"] but the script needs a variable file name. I don't understand the basic situation here. You are trying to open your local FMP file from where? And where is the "variable file name" kept? Edited August 24, 20169 yr by comment
August 24, 20169 yr Author @comment -- I will be using Keyboard Maestro. KM will generate each filename, folder name and initiate FM (or FM Script) for each iteration -- hopefully passing these variables into FM (on file open) or FM Script. KM will loop through multiple iterations.
August 24, 20169 yr 4 minutes ago, fm8443 said: I will be using Keyboard Maestro. I am afraid I am not familiar with Keyboard Maestro. IIUC, it's a keystroke macro utility. If so, your question could be posed as: can I run an import script and type in the path to the source file at runtime? I don't think that's possible directly - but perhaps you might have the script open a custom dialog with a global input field where the macro could type in the path. Then set a variable to the contents of the global field and use it in the import script. Caveat: thoroughly untested, written entirely off the top of my head.
August 24, 20169 yr Author Yes, KM should be able to issue keystrokes on top of FM's dialogs. Not too clean a solution but may work. But can I startup FM 14 Pro on the Mac by using the fmp:// syntax (and pass a script param and vars) from a web browser e.g. see Example in section 4 here: http://www.twdesigns.com/fmp_url_protocol/ ? If so this would be ideal.
August 25, 20169 yr Yes, that can be done - the FM file needs to be in the Documents directory for something like this to work: fmp://user:pwd@~/Database.fmp12?script=Test¶m=DoesThisWork
August 25, 20169 yr Author I've got it partially to work but have hit syntax error/s: From my Safari URL Box I run: fmp://Admin:@~/Filemaker_DATA/MAIN_ZZZZ_Database/MAIN_ZZZZ_Database?script=MAIN_Add_ADP_Report_All_Steps¶m="file:Filemaker_DATA%2FMAIN_ZZZZ_Database%2FUNALTERED_MONTHLY_REPORTS%2F2016_ADP%2Fadp-report-4-2016.xls" This does startup my FM 14 Pro data file and starts to run the MAIN_Add_ADP_Report_All_Steps script. This script is: set variable [$adp_report ; Value: Get ( ScriptParameter ) ] Import Records [Source: "$adp_report" ; Worksheet: "" ; Add; Mac Roman ] This script fails (when trying to do the "Import Records" step presumably) with error message: "The file "$adp_report" could not be found and is required to complete the operation". Am I getting the syntax wrong for the ¶m part of the FMP:// command? Or using Get ScriptParameter incorrectly to set the Excel filename variable $adp_report ? [ I have also tried the fmp:// command without the double quotes on the param= part........to no effect. I get exactly the same error as described. ] Edited August 25, 20169 yr by fm8443
August 25, 20169 yr Author As-is, I can't (?) turn Script Debugger on because I'm initiating everything externally from the fmp:// url But if I take the param= part and simply copy the string: file:Filemaker_DATA%2FMAIN_ZZZZ_Database%2FUNALTERED_MONTHLY_REPORTS%2F2016_ADP%2Fadp-report-4-2016.xls into the "Import File" box (replacing the variable $adp_report ) then the command & script works! I don't understand why my param= part is not setting the script parameter which should be setting the $adp_report variable. Edited August 25, 20169 yr by fm8443
August 25, 20169 yr Try running the URL with the file already open, and the Script Debugger turned on. Or temporarily make the variable $$adp_report, so you can check it's value in the Data Viewer afterwards.
August 25, 20169 yr Author 1) I did this: "Try running the URL with the file already open, and the Script Debugger turned on." I get the error message before seeing anything in Script Debugger's "Current" Window. Seems like $adp_report is not getting passed the param / is not being set. 2) I changed the variable to $$adp_report twice in the script which is now: set variable [$$adp_report ; Value: Get ( ScriptParameter ) ] Import Records [Source: "$$adp_report" ; Worksheet: "" ; Add; Mac Roman ] No effect. Got exactly same result in Script Debugger's "Current" Window etc.
August 26, 20169 yr Author UPDATE: Think I've found the problem: I had a sub-script called IMPORT EXCEL called by my Top Script (MAIN_Add_ADP_Report_All_Steps). My 2 script steps: set variable [$$adp_report ; Value: Get ( ScriptParameter ) ] Import Records [Source: "$$adp_report" ; Worksheet: "" ; Add; Mac Roman ] were in the wrong script. I moved them into the top-level script and out of the IMPORT EXCEL sub-script and it now appears to work....
Create an account or sign in to comment