Jump to content

Correct syntax to open a script in another file


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

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.

Link to comment
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).

Link to comment
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.

Link to comment
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
Link to comment
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.

 

Link to comment
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.)

 

 

Link to comment
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.

 

 

 

 

 

Link to comment
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.

Link to comment
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."

Link to comment
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.

Link to comment
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?

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

This topic is 1959 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.