Use FileMaker scripts for different tasks at the same time

Use FileMaker scripts for different tasks at the same time

How to achieve more with your FileMaker scripts


7. April 2021In TipsBy Karsten Risseeuw8 Minutes

FileMaker Scripts are used to standardize workflows. It is the “programming language” of FileMaker, so to speak. Usually actions are triggered by clicking on a button. A script in the background then performs the task. Workflows can thus be created with great ease. As the application grows, the number of scripts also grows until there may be hundreds of scripts. Something like this quickly becomes confusing. Many scripts often consist of only a few lines. Can this be simplified?

Yes, you can simplify scripts. The following procedures have worked well for me:

  1. Create scripts per layout if possible
  2. Group scripts per table if possible
  3. Combine several smaller scripts into one script.

The basic idea should always be to create smaller units that you can test well, and then combine them to create larger tasks.

Control all scripts with if-requests

As a rule of thumb, I call each script with a script parameter. If you call a script without a script parameter, nothing happens. The functionality is always contained in an if-query. This not only increases security, but also allows one script to be used for multiple tasks.

Many scripts perform only minor tasks. For example, I often have a settings page that I can customize. I can read and write these settings. Both tasks (saving/importing) can be easily accommodated in a single script. For example, like this:

In this screenshot you can see a simplified representation. At the top is the name of the script. You can add more information there if you want. Below there is a list with all script parameters, with which the script can be called. This serves for the clarity and is at the same time something like an index to the script. The script parameters show the sections in the script. Only then follows the actual functionality.

  1. Script name
  2. List of script parameters with which the script can be called
  3. The actual functionality in if-requests

Each section then appears with an if-query. For example, if I want to do the reading and writing of presets in a script, the script might look like this:

If [ Get(ScriptParameter) = “write” ]
*** HERE YOUR LOGIC ***
End

If [ Get(ScriptParameter) = “read” ]
*** HERE YOUR LOGIC ***
End

This gives me a script with which I can solve various tasks. This reduces the number of scripts. I have scripts that often do up to a dozen smaller tasks. This is not a requirement, but a way to make your job easier.

Use subtasks

With this approach, subtasks can be neatly separated and still be kept together. Instead of using a script with many sub-scripts, perhaps the tasks can be combined into a single script. Each if-query can be a subtask. This keeps the scripts organized and you can call subtasks one after the other or individually.

Subtasks can be activated in two ways:

  1. You call the same script from the script with a different parameter
  2. One adds another parameter to an if-query, which is then picked up further down in the script.

For the second variant, here is an explanation: Of course, script parameters should be set when the script is called for the first time. However, this does not stop you from always specifying the next step in the course of the script – for example, with a variable.

If [ Get(ScriptParameter) = “write” ]
*** HERE YOUR LOGIC ***
set variable [ $NextStep ; value: “output” ]
End

Here a variable is set at the end of an if-query with the keyword “output”. This variable should point to the next step named “output”. Insofar as this section is included in another if-query, after the completion of the first section, the second section should now be activated. For example, you can do it like this:

If [ Get ( ScriptParameter ) = “output” or $NextStep = “output” ]
*** HERE YOUR LOGIC ***
End

The addition to the if-query is now formulated in such a way that this part can be controlled either with a script parameter or with a local variable from the script. This allows you to “work through” several sections in one run without having to call up the script multiple times.

Does this information make sense? This may not just be a question of programming style, but also has to do with the type of project you are working on. I always start with the question: “How do I keep everything as simple as possible?”.

Why should one use this?

After I posted the text above on social media, the question was asked, “Why use this?”. I realized that I had not yet said anything about the reasons why I came to this structure. Now here are a few words:

First of all, it’s just one (of many) ways to write scripts. There are no guidelines. For me there were various experiences that led to this method:

Challenges

  1. I had hundreds of scripts in larger databases. Many of them were made up of only a few lines.
  2. Often I had integrated the same function in several places, or I used multiple scripts for the same thing.

“The bigger the solution” now also meant “the more complex”. That’s what I wanted to change.

Optimization requests

  1. Reduce the number of scripts
  2. Avoid redundancies in the functions
  3. Make the structure of all scripts easier
  4. Optimize the possibilities of each individual script.

The ideas of a modular development of FileMaker functions showed me how this could be made possible. The following approaches in particular proved to be helpful:

Implementation

  1. If possible, group scripts according to table / layout
  2. Ideally, reduce scripts to your “own” tables / layouts
  3. Combine several functions per table / layout in a single script
  4. Each script has several «parts» that can be controlled by a script parameter.

Should this be a rigid rule now? No. However, it has simplified all scripts for me and drastically reduced the number of scripts. This has proven to be a valuable method for me to simplify my code.


How do you process text files with hidden BOM characters in FileMaker?

How do you process text files with hidden BOM characters in FileMaker?

Sample file


23. March 2021In ExamplesBy Karsten Risseeuw3 Minutes

BOM characters are invisible characters that can be added to a text file as additional information. They are used, for example, to define a specific text coding. In FileMaker add-ons, JSON files are given such a BOM character. This example file shows how to deal with it.

FileMaker add-ons use JSON files with BOM characters

BOM characters are invisible. Anyone who opens a text with a BOM symbol in a normal text editor will not see this symbol. Nevertheless, the character can decide whether a file is recognized by a software or not. The JSON files of a FileMaker add-on can easily be processed with FileMaker. If you want to save the information back into a JSON file, the problems begin. This has nothing to do with whether the text is saved with the correct encoding, it needs additional information – that of the BOM. If the BOM is missing, Filemaker can no longer recognize the add-on.

How to find a BOM character

BOM characters become visible when opening a text file with hexadecimal encoding. This preserves all parts of the text – not just the text, but also hidden characters. “Hex Fiend” on Mac, for example, is an editor that can display files in this way. In the screenshot below you can see the BOM on the left (the first 6 characters: EF BB BF ). In the right part this is represented by three … These hints are missing in normal text editors.

JSON file from a FileMaker Add-on opened in Hex Fiend.

What are BOM characters?

BOM stands for Byte Order Mark and is a mark in the text. The following description comes from Wikipedia:

“A byte order mark (BOM; German byte order mark) is a characteristic byte sequence at the beginning of a data stream that encodes the Unicode character U + FEFF (English zero width no-break space).”

The whole article on Wikipedia describes the type of character and different variants. More on this at > Wikipedia

Example file for processing with FileMaker

A free sample file shows how the information in an external text file can be read and rewritten including a BOM character.

BOM-characters (EN) (#8)

Free Download

Please fill out this form. The download link will be sent to you by email.


Macbook and accessories. Home office.

A central website for FileMaker developers

A central website for FileMaker developers

Simplified and focused: fmstarter.com will now continue to grow


15. March 2021In GeneralBy Karsten Risseeuw2 Minutes

The fmstarter.com website is being expanded. In the last few years there have been mostly free tools here. Commercial solutions were sold via kursiv-software.com. That is changing now. The website fmstarter.com will target FileMaker developers and integrate everything that is needed for this.

Vision and mission

The vision for this website is quickly told: In the future, all information and products for FileMaker developers will appear here. This becomes a bundled resource. In the past, commercial products were sold through our shop on kursiv-software.com. That already changed this year. All FileMaker products are now available at fmstarter.com.

The mission is just as simple: we want to simplify development with FileMaker. Everyone should be able to work with FileMaker with fun and success. Free sample files as well as commercial products are offered for this purpose. An online course offering is also in preparation.

FileMaker and low code

FileMaker is a low-code product. Even without programming knowledge, you can quickly build a solution that can simplify business processes. It doesn’t stop there, of course. With increasing requirements, you need better basics and more know-how. This is where Kursiv Software steps in. Our experience makes your entry into the world of FileMaker much easier. Not only that, experienced FileMaker developers also benefit from our solutions because they accelerate processes or provide a solid foundation for new projects.

FileMaker Developer Newsletter

Another innovation is the newsletter, which is now specially made for FileMaker developers only. You can subscribe to the German newsletter on the German side of this website, while the English newsletter is offered on the English side of the website.

Building for the future

Anyone who builds software builds for the future. What I do today will take me further tomorrow. That’s why it’s worth investing in FileMaker. The platform is stable, versatile and has been successful for decades. Kursiv Software wants to contribute a few things to this ecosystem. This is what this website is for.

Who else should get to know our website?


How to recognize iPad and iPhone in FileMaker

How to recognize iPad and iPhone in FileMaker


10. February 2021In FM Starter, TipsBy Karsten Risseeuw1 Minutes

If you create a file for iOS devices, you probably have to be able to distinguish between iPhone and iPad. When starting the file, you need to create a query, based on which a layout for iPhone or iPad will be navigated. This should be possible with the status query:

Get ( ApplicationVersion )

If the file runs on the iPhone, the result is “Go”, while on the iPad it returns the result “Go_iPad”. A complete query can be created as follows, according to FileMaker Help:

Patterncount ( Get ( ApplicationVersion ) ; “Go” ) for iPhone, and
Patterncount ( Get ( ApplicationVersion ) ; “Go_iPad” ) for iPad

If one implements this query, it becomes apparent that this does not work well. Both requests recognize an iPhone. This does not change even if you only enter “iPad” for pattern recognition instead of “Go_iPad”.

A simple solution is to search only for iOS and then explicitly query the device:

Get ( Device ) = 4, for iPhone
Get ( Device ) = 3, for iPad

This works flawlessly.

Adjustment for FM Starter

The next update of FM Starter will include this for the navigation. If you want to adjust this already today, you have to do this here:

Script: GN GetSystemLayout, line 25.

Let (
a = Get ( ApplicationVersion ) ;

Case (
PatternCount ( a ; “Pro” ) ; 1 ;
Get ( Device ) = 4 ; 2 ;
Get ( Device ) = 3 ; 3 ;
PatternCount ( a ; “Web” ) ; 4 ;
1 )
)


42,000 Downloads

42,000 Downloads


21. January 2021In GeneralBy Karsten Risseeuw1 Minute

Amazing! By early 2021, the sample files and FileMaker modules on this website had been downloaded over 42,000 times. This shows that FileMaker developers around the world are looking for good solutions, getting started guides, starter files and examples.

FM Starter will be enhanced

The second round is now underway. The counter has been reset. The website will be revised gradually. Some older files will disappear, but new posts will appear more regularly. We are also preparing something that will help FileMaker developers in particular. However, nothing is revealed about this here yet.

Wait and see!


Card windows in FileMaker Pro

Card windows in FileMaker Pro


Sample file and video introduction.

This example was created based on a presentation titled “UFO’s and Card Windows” for fmnext.ch in November 2020. What do UFOs have to do with Card Windows in FileMaker? Not much at first glance. At a second glance, however, a few similarities can be discovered, which exemplify the peculiarities of Card Windows.

How do Card Windows work in FileMaker Pro?

Card Windows were first introduced in FileMaker Pro 16. It was a new kind of window. When using the New Window command in a script, you can specify the type of the window. The type “Card” was specified as new. The Card window was born. To begin with, Card Windows were built into FileMaker Pro for Mac and Windows. The application for a desktop computer is perfect. At that time, WebDirect, the Internet edition of FileMaker, was left out. Claris has now made WebDirect suitable for Card Windows with FileMaker Pro 19.

Card Windows in FileMaker
Card Windows in FileMaker

Beispieldatei. Benötigt FileMaker Pro 19.
Sample file. Requires FileMaker Pro 19.

Size: 2 MB
Version: 1.31

Update: FM Registrations 1.5 released

Update: FM Registrations 1.5 released

Simpler and better documented


15. October 2020In FM RegistrationsBy Karsten Risseeuw2 Minutes

FM Registrations 1.5 is a major update, although technically not much has changed. These are the changes in the current update:

  • simplified user interface
  • New manuals in German and English
  • New Videos in German and English
  • Adjustment Expiration date in code (see below)
  • Updated example file.

The update is free for current users, as long as the purchase was not made more than a year ago. The update can be downloaded directly from your account on kursiv-software.com.

Simpler handling

FM Registrations has been completely modernized with this update. There is a simpler user interface and the workflows have been streamlined. Overall, the handling as well as the implementation in the own FileMaker application is simplified.

Verfalldatum wird als Zahl gespeichert

FM Registrations bietet die Möglichkeit ein Verfalldatum in dem Lizenzcode mitzugeben. Das ist insbesondere dann interessant, wenn man die Software beispielsweise mit Jahreslizenzen verkauft. Nun speichert FileMaker jedoch eine Lokalinformation in jeder Datei, die auch dann beibehalten bleibt, wenn man die Datei an einem anderen Ort aufmacht und nutzt. FM Registrations hat eine europäische Datumsformatierung. Wurde die Datei in den USA aufgemacht, wurde ein definitives Verfalldatum nicht im amerikanischen Format, sondern im europäischen Format (entsprechend der Lokale in der FileMaker Datei) gespeichert. Das konnte zu falschen Datumsangaben führen. Mehr dazu auch im Beitrag «Datumsformatierung in FileMaker».

Neu wird ein definitives Verfalldatum als absolute Zahl im Code eingebunden. Damit werden die Probleme der Lokale Information umgangen. Das Datum wird durch LiesAlsZahl ( [Datum] ) in eine Zahl umgewandelt. Die Rückwandlung erfolgt durch LiesAlsDatum ( [ZAHL] ) und muss vom Entwickler so in der eigenen Lösung berücksichtigt werden.

Die aktualisierte Beispieldatei zeigt, wie dies funktioniert.

FM Unlock

The example file contains the unlock module. This has been renamed to “FM Unlock” to make the function immediately obvious. The module “FM Unlock” has to be integrated into the own file by the developer, so that license codes of FM Registrations are evaluated correctly.

Encryption and decryption is done using a secret code created with the “FM Registrations” application. Read more on the product page.

 

The product page also contains the manuals and all new videos about the product.


Date formatting in FileMaker

Date formatting in FileMaker


Sample file. The importance of localization

The local information in each FileMaker file

Date settings in Europe and in the States, for example, are different.

The specification “01.10.2020” is interpreted in Europe as “October 1st, 2020”,
however, in the States as “January 10, 2020.”

In order that FileMaker knows how to understand a date specification, the local information is anchored as a fixed specification in the file when a file is created. On one hand, this allows an interpretation of the date, but should the file open later on another operating system, FileMaker can match new date entries (between system settings and the information anchored in the file). This ensures the integrity of various date entries.

Da es weltweit unterschiedliche Interpretationen von Datum und Uhrzeit gibt, verwaltet das Betriebssystem unterschiedliche Optionen. FileMaker puts the system settings for formatting (the local information) into the file as soon as it is created.

Regional settings

FileMaker sets a fixed point for interpreting the date, and this fixed point (or local information) does not change when the file is opened on a system with different date formatting. Internally, the fixed point remains, even if a date is entered differently due to a different operating system.

Example
If a FileMaker file is created in Europe, but then opened in the USA, the following situation occurs: Internally in the file the date interpretation was set to the European DAY/MONTH/YEAR. However, for the user in the USA, the system settings are MONTH/DAY/YEAR. In date fields this is no problem – FileMaker can adjust the display (!). Internally, however, the European structure remains intact. This can lead to problems.

Date calculations are unpredictable

There are problems with date calculations when the settings of the file are different from those of the user. Two sample files are included here as a download: It is the same file, but once as a file with European reference and once as a file with American reference. If you open a file, the following happens:

When you open the file that is not part of your system settings, the following happens: Dates written to text fields get the file-internal formatting (which is wrong). There are also problems with date calculations. The best way to see this is to open both files in parallel.

In this example: The system runs with EU settings. The EU file is OK.

In this example: The system runs with EU settings. However, the file was created with American settings. Now the date calculations are no longer OK.

Neutral storage of dates

A date can be saved not only as a “date”, but also as a “date number”. FileMaker counts the days from January 1 of year 0001. Every date since then can therefore be represented as a number. This number is not dependent on any formatting. The date can thus be defined as numbers:

ReadAsNumber ( [DATE] )

To convert this number back to the date the following applies:

ReadAsDate ( [NUMBER] )

So with these two specifications dates can be stored neutrally, or transferred as a number from one file to the next. When converting back to a date, the date settings of this file then apply where it is interpreted.

Example
October 1, 2020 has the number “737699”. In a European file, it is converted to “01.10.2020”, while in an American file, the conversion is “10.01.2020”.

Removal of local information

The local information that FileMaker stores when creating a file cannot be modified. There is only one method to “reset” the file, namely by creating an empty clone of the file.

In the sample file there is a button with which such a clone can be created very easily. The local information of the file is reset when it is opened and therefore depends on the particular system that the user is using. The clone function makes it relatively easy to test the behavior in different system environments.

Program date neutrally

No FileMaker file today is neutral with respect to date processing. However, one can consider whether to aim for a neutral development of new solutions (with the help of the date number).

New features from FileMaker Pro 19.1

Claris has added two important features in the latest version:

  • Get ( SystemLocaleElements)
  • Get ( FileLocaleElements )

With these two functions you get a complete overview of all settings, nicely packed in JSON – once from the system and once from the file. From this, for example, the current data can be read out of the system and used for feedback, formatting or other purposes.

We are talking about system settings and file settings. Of course, programmed characteristics, such as language settings of a multilingual solution, are not considered.

Date Formatting
Date Formatting

Datumsformatierung. Benötigt FileMaker Pro 19.
Date formatting. Requires FileMaker Pro 19.

Size: 99 kB
Published: 3. March 2021

File paths in FileMaker - the basics

File paths in FileMaker - the basics


File paths are used in FileMaker to do something outside of FileMaker. For example, to import or export something. How file paths are created is shown in this sample file. Immediately a few application examples are also provided, how to import pictures, videos, texts or other files.

This sample file is about:

  • File paths in FileMaker
  • import and export
  • Import individual files or entire folders
  • Simple scripts for basic functions.
  • Extract filenames from containers
  • Calculate file names for export

FilePath Basics
FilePath Basics

Dateipfade in FileMaker. Beispieldatei. Benötigt minimal FileMaker Pro 18.
File paths in FileMaker. Requires FileMaker Pro 18 or higher.

Size: 130 kB
Version: 1.20
Published: 3. March 2021

Simple Backup 1.4 for FileMaker

Simple Backup 1.4 for FileMaker

Small improvements simplify handling


19. September 2020In NewsBy Karsten Risseeuw1 Minutes

It is often the small things that simplify life or practically improve a function. We have now added such a small function to the last update of SimpleBackup.

SimpleBackup is a small FileMaker module that allows you to take snapshots of the current file in local installations. External files can also be included. The snapshots are saved in a directory of your choice, and each backup copy gets a timestamp in the filename.

In version 1.4 there was only a small change: The backup directory is shown after the backup. This function is done with the script command “OpenURL” following the pattern:

“file:/” & [BACKUP PATH]

For this to work, the use for URLs of scripts must be enabled in the security settings.

Simple Backup