Jump to content
Sign in to follow this  
John T

fmp17 Correct syntax to open a script in another file

Recommended Posts

I have great hopes that someone can help me...please.  Although I am very new to this forum, I am a long time user of FileMaker products.  I recently migrated from FMP 13 up to FMP 17 Advanced.  In FMP 13 I was using a plug-in to allow me to open and run a script in another file.  Unfortunately, that plug-in no longer works in FMP 17 as it is no longer supported and I was told that the new version of FileMaker allows users to perform all the functions that the plug-in previously offered.  As a result, I have been trying to bring myself up to speed with FileMaker's new scripting methodology (which I am no fan of).  I have exhausted all the resources that I have accessed and am lost.  In greater detail here is my problem:  In total I have 11 different files which are the core of my book database.  Two of those files allow me to create the 200 or so static web pages I use to populate my web site.  The primary file is one called "Inventory" which contains active records for well over 4,000 books.  A second file is called "Web pages" where there is a separate record for each of my 200 plus web pages.  In that file there is a field called "Script name" which references a script of the same name which resides in the file Inventory.  I need to create a script which allows me to call up the script name appearing in Web pages and then run that script in Inventory.  All of my efforts to create such a script so far have been complete failures.  I hope someone can please write out the actual lines to accomplish this feat.  Thank you in advance.

Share this post


Link to post
Share on other sites

FMv17 changed the 'Perform Script' command slightly and allows you to specify the name of the script via a calculation (which can also be a variable). In the 'Perform Script' command you can also specify another database file in which the script can be found. That should work in your case.

Note that you will need to create a data source to this database for it to work. You'll need to create a static script (ie 'RunScript') in the inventory DB that is always invoked and pass the script to run as a parameter. Then in 'RunScript' you take that parameter and pass it to a 'Perform Script command by naming the script name (not from a list).

Share this post


Link to post
Share on other sites

Olger, thank you for your kind note.  I gave the Perform Script function a try.  It started with:

Perform Script [Specified by: Name ;  ___ ; Parameter: ___ ]

where I tried to fill in the blanks with the following parameters:

Perform Script [Specified by: Name ; "Script name" ; Parameter: "Inventory.fmp12" ]  which did not work.

Perform Script [Specified by: Name ; "Script name::Web pages.fmp12" ; Parameter: "Inventory.fmp12" ]  also did not work

Perform Script [Specified by: Name; "Script name::Web pages.fmp12 ; Inventory.fmp.12"]  did not work.

At this point I was beyond frustration.  But, your second paragraph gave me an idea to use a completely different approach.  I created a new global field in Inventory and then created a short script in Web Pages to copy the contents of the field "Script Name" to a new global field in Inventory.  I also created a new script in Inventory as follows:

Go To Field [Inventory::gTmep Script Name from Web Pages]
Perform Script [by name: Get (ActiveFieldContents)]
Set Field [Inventory::gTemp Script Name From Web Pages; ""]

This worked perfectly.  However, I can not understand the first method of trying to activate the appropriate script from Web Pages.

By the way, during this process I found another thing which I really dislike in FMP 17.  It does not allow one to copy into a clipboard the contents of a script so that it can be pasted into a document like this.

Share this post


Link to post
Share on other sites
11 hours ago, John T said:

I need to create a script which allows me to call up the script name appearing in Web pages and then run that script in Inventory. 

In order to read the script name directly from a field in the "other" file, you must have an occurrence of the field's parent table on the relationships graph of the calling file.

If the ScriptName field is not a global field, then you must also have a relationship defined in such a way that will read the value from the correct record.

Once you have all that, you can call the target script as:

Perform Script [ By name; "ExternalTable::ScriptName ]

 

2 hours ago, John T said:

I also created a new script in Inventory as follows:

Go To Field [Inventory::gTmep Script Name from Web Pages]
Perform Script [by name: Get (ActiveFieldContents)]
Set Field [Inventory::gTemp Script Name From Web Pages; ""]

I don't see why you need to go the field, when you can do simply:

Perform Script [by name:Inventory::gTemp Script Name from Web Pages] ]

 

2 hours ago, John T said:

another thing which I really dislike in FMP 17.  It does not allow one to copy into a clipboard the contents of a script so that it can be pasted into a document like this.

I don't think this is new in version 17.

 

---
P.S. Please use the default font in your posts here.

 

 

Edited by comment

Share this post


Link to post
Share on other sites

Hello Comment,  Thank you for your comments on my problems with this script issue.  Before going further on the actual script I have to say that setting up a relationship between the files of Inventory and Web pages is not possible.  One book in Inventory can have several different scripts in Web pages which access it.  For example: a book by Robert Frost is accessed by the script for the individual page for Robert Frost as well as a more general page for books of poetry.

Now, on to the specific script issue:  I tried your suggestion (which makes perfectly good sense) so I created a script which  read:

Perform Script [by name: Inventory.fmp12::gTemp Script Name from Web Pages]

but it was not accepted by FM with an error message stating it would not accept the first bracket as it expected "A number, text constant, field name or "(" is expected here."  I replaced the first bracket with a "(" and then FM's error message highlighted "by name: Inventory.fmp12" and read "the specified table can not be found".  Even taking out the ".fmp12" so that my script conformed perfectly with your suggestion made no difference.  Is it any wonder that frustration abounds with this new scripting methodology!

It appears that I was wrong about being able to copy to the clipboard and paste to non-FileMaker applications the clipboard contents.

I would be happy to use "the default font" in my posts, but I do not see anything in the above format line of symbols which allow one to do that.

 

Share this post


Link to post
Share on other sites

I am afraid I could not quite follow your description. In general, when one table requires information from another, a relationship is not only possible, but required.

If, as you say:

34 minutes ago, John T said:

One book in Inventory can have several different scripts in Web pages which access it. 

then no matter how you access the information in WebPages, you must have something in Inventory that would enable you to choose the correct web page to get it from. That something can - and most likely should - be the basis for the relationship.

 

38 minutes ago, John T said:

I created a script which  read:

Perform Script [by name: Inventory.fmp12::gTemp Script Name from Web Pages]

but it was not accepted by FM

Well, my post should have read:

Perform Script [ By name; Inventory::gTemp Script Name from Web Pages ]

and to set it up, you need to [1] select "By name" from the drop-down menu next to "Specified:" and [2] paste the fully- qualified field name Inventory::gTemp Script Name From Web Pages into the Specify Calculation window that opens when you click on the adjacent blank space to the right. Or, preferably, select the field from the list of fields in the left pane of the Specify Calculation window.

(In my defense, I copied the code from your post and simply replaced Get (ActiveFieldContents) with your field name - and that's basically what you need to do too.)

 

 

Share this post


Link to post
Share on other sites
9 hours ago, John T said:

Hello Comment,  Thank you for your comments on my problems with this script issue.  Before going further on the actual script I have to say that setting up a relationship between the files of Inventory and Web pages is not possible.  One book in Inventory can have several different scripts in Web pages which access it.  For example: a book by Robert Frost is accessed by the script for the individual page for Robert Frost as well as a more general page for books of poetry.

It's struck me previously odd that your book database consists out of 11 files. Can't they all go into one database? It would (probably) make things a lot easier. Or is this a database that has been migrated from a (pre) FM7 multifile to FM13 and then to FM17?

9 hours ago, John T said:

Is it any wonder that frustration abounds with this new scripting methodology

I started briefly with FM12, then worked with FM13 for the first few years. The scripting environment has evolved over the last versions, but not significantly changed. The Script Editor UI has changed a bit, since v13, with the biggest difference probably that the script steps have moved to the right, and the left now has a list of scripts, but that change is (imho) for the better and streamlines development.

But the scripting hasn't changed significantly. So this remark has me puzzled.

 

 

 

 

 

Share this post


Link to post
Share on other sites
1 hour ago, OlgerDiekstra said:

It's struck me previously odd that your book database consists out of 11 files. Can't they all go into one database? It would (probably) make things a lot easier.

That too. I was only waiting for the immediate problem to be resolved to say something about that.

Share this post


Link to post
Share on other sites

Yes, occasionally I have given thought to the idea of merging some of my 11 separate files, but let me give you all some insight into why that hasn't happened.  I started using FileMaker many years ago starting out with FMP 5.  Prior to leaning about FM I had experience with DB2 and another program the name of which I have forgotten.  It took me 14 months to create a very thorough, relational book database for my books, my customers, market data and shipping statements/invoice files.  They were all separate, but related files.  Through the years I have added more related files to keep track of profit, monthly profit, customer credit card data, book appraisals, and most recently bookbinding projects/billing.  Once cell phones became ubiquitous I started to imagine the day I would be able to load parts of my database on to my iPhone so that I would have some critical information available to me when I was in the field.  Once FileMaker Go appeared I knew that my dreaming would become reality.  But to put all the multiple files covering things like profit, credit card data, bookbinding, etc. on the iPhone would only clog up FileMaker Go with unnecessary stuff.  So, I felt that keeping them separate would allow for both a piecemeal download to FM Go and also keep the credit card file separate for security purposes.

At this point I consider my scripting problem solved.  The workaround that I came up with may not be the most efficient in terms of scripting, but it works.  And going back to the idea of consolidating files I am stopped by considering the old adage - "If it isn't broken, don't fix it."

I will be the first to admit that one of my current minor complaints about having migrated to FM 17 Advanced from FMP 13 is that each of my separate files when opened requires that it be closed before I can quit the entire book database.  Previously under FMP 13 I could close the open open file and all files would close with it.  A picture attached below might help to explain what happens now.

image.png.0a2485534282bbc52448589e6c3ece20.png

I didn't really complete the first sentence of my last paragraph.  It should have read:

"I will be the first to admit that consolidating files would solve my one current minor complaint about having migrated to FM 17 Advanced from FMP 13 which is that each of my separate files when opened requires that it be closed before I can quit the entire book database."

Share this post


Link to post
Share on other sites

There's a script command to close FileMaker, which will close all files: "exit application". You can run that as part of a "OnLastWindowClose" script.

I think you'll find having just one DB work much better if you start to develop something for FM Go. It's much easier to extract stuff form one DB than it is from 11. You'll be creating an entire new database for Go if you want to take some info offline. Generally, layouts for desktops will not work on mobile devices.  Developing for touch devices is very different than for a desktop.

Share this post


Link to post
Share on other sites

Hi Olger,  Thank you for the suggestion of using "exit application".  I just added it to my closing script and it worked very nicely closing all of the open files.  Great!  Another problem solved.

Yes I see the wisdom of combining some of my files so that operating it/them on FM Go will be more seamless.  Is there some easy way of consolidating say my market data file into my Inventory file without having to add all new market data field names into the Inventory file?  Possibly by going to File > Manage > Database > Tables > Import > Market Data?

Share this post


Link to post
Share on other sites

Always work off a backup. So make a copy of the inventory DB and use that to import your other files.

You can open both files and copy tables from one to another. If you have multiple tables in some databases, then your relationships won't come across I don't believe.

Also pay attention to how you import from one to another. Generally custom functions first, then tables,  and finally layouts and scripts. Scripts can reference layouts, and layouts can use scripts, but checking scripts is easier than checking layouts for missing script references.

Then restore any relationships, and import data.

Share this post


Link to post
Share on other sites

Hello Olger,

Thank you very much for all of your guidance regarding the process to follow to combine files.  I spent most of this afternoon giving it a try on a backed up version of Inventory.  I tried migrating into it the least complex file I had (Market Data).  It did work until I started looking at the scripts that would have to be modified to fit the new configuration.  That's when I hit a road block which made me realize that if I ever attempted to integrated some of my more complex files into Inventory it would take a long time to accomplish.  My business just can not stand to be put on hold for days at a time while I do that.  I will just have to live with many different, but linked files.  Thanks again.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Content

    • By ChangeAgent
      Is this at all possible?
       
      I want to have two buttons that will each do the following. 
      Have one button to ‘Strike Thru’ text that is highlighted before.  Means not all the text in the field will be changed.
      And one button to change the text colour to Red, again highlighted before.  Means not all the text in the field will be changed.
       
      Any tips how to do this?  Please bare in mind I am a FMP beginner.  Thanks. 
    • By lutfishah
      Dear All,
      I am trying to put a conditional formatting validation which turns Red when the value is entered wrong. Basically all my tries have failed so I would like your help here.
      The criteria of entering a value is 
      xxxx-xxxx-xxxx-xxxx
      1111-2222-3333-4444
      1. Length of value is  = 19     OR      this should be a 16 digit number, in groups of 4 separated with dashes
      2. Non-Digits characters are not valid.
      Please could you help me with this and I will really appreciate. 
      Many thanks
      Regards
      Lutfi
       
    • By Koonce
      I have filemaker server on virtual server, I have a script that exports emails and or names i cannot get the file to be saved to the local desktop it tries to save to server with an error when i do manually it works fine so i am doing something wrong...
      Thanks in advance
    • By ThomaStudios
      I have been using FM17Adv for some time.  I am on a MacPro 12-core tower and I had been running macOS Sierra.  All the internal scripts I had in one database worked perfectly.
      I recently updated to High Sierra and now I am getting script errors I don't understand.  And this is from the same exact file I used previously.  I have one script where I want it to open a folder in Dropbox so I can access files there.  But I am getting this error:  Can’t make "Dropbox" into type integer.  Then I get a -1700 error dialog immediately after that.  Can anyone explain how I can fix this.  I have not been able to find anything online.
      The script is a native AppleScript, and I suspect that has something to do with this.  Here is the script:
      tell application "Finder"     activate     open folder " Pieces 2011" of folder "Teaching Material" of folder "Dropbox" of "  ThomaStudios 4TB"     select Finder window 1 set position of Finder window 1 to {2877, 167} end tell
      Thanks.
      J D Thomas ThomaStudios
       
    • By Caio Euzébio
      Hi Guys,
      There are any logic or resource that i can use to make like a "text to columns".
      Make text from field one flow to another fields but only with in the middle of coma regarding your sequence, like a excel?
      Full text with Comas Text1 Separated Text2 Separated Text3 Separated How,Are,You? How Are  You? Could please help me, i need a lot of this resource.
       
       
×
×
  • Create New...

Important Information

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