
General comments in the script header
At the beginning of the script there should be a general comment block in which the author, the date, contact details and the description ( task from the Script) are noted.
# ------------------------------------------------------------------------------- # Jens Liebelt # May 2011 # web@jens-liebelt.de # # FM4Web # Create slider for the page header of the web edition. # # This script changes the layout. # When called as a partial script, the calling script must return to the # original layout. # -------------------------------------------------------------------------------
History in the FileMaker script
If the script is changed during the development of the Database is changed, a comment block can be inserted for the history. The history shows which changes were made when and who made the changes.
# ------------------------------------------------------------------------------- # History # # 21.05.2011 Bugfix # Jens Liebelt # Incorrect state of variable $_filename after execution # from the subscript Calculate image size. # -------------------------------------------------------------------------------
Variables in the FileMaker script
Complex scripts generally use variables for process control and the calculation of field values. In principle, this option should always be used - however, it is necessary to decide on a standardized spelling and designation for variables. Global variables should be used sparingly and initialized in a partial script so that you can always see which global variables are used in the application. Local variables whose validity is limited to the current script should be noted in a comment block.
# ------------------------------------------------------------------------------- # Local variables # # $_filename # $_filepath # $_fileisuffix # -------------------------------------------------------------------------------
Script parameters
The use of partial scripts and local variables often requires the use of script parameters (arguments). In this way, the value of a local variable can be passed to a partial script without losing the initial value in the current script - if required, the current value can be replaced by the result of the partial script (Get ScriptResult).
# ------------------------------------------------------------------------------- # Script parameters # $_filename - Pass on to subscript Build file name # $_filipfad - Build pass to subscript filename # -------------------------------------------------------------------------------
Script sections - Structure of the script
The sections in a script should be commented in blocks. This means that each section that represents a self-contained sequence of commands is summarized in a comment block.
#-------------------------------------------------------------------------------- # Slider 1 # Further explanations can also be placed here, # this depends on the complexity of the block. #-------------------------------------------------------------------------------- If [ Server::_slider pic 1 ≠ "" ] Set variable [ $_filename; value: "slider_1" & characterRight ( Server::_slider 1 imgPath ; 4 ) ] Export all field values [ Server::_slider pic 1; "file:html/images/slider/$_filename" ] Set variable [ $_slider; value:$_slider & "/>¶" ] End (if) #-------------------------------------------------------------------------------- # Slider 2 #-------------------------------------------------------------------------------- If [ Server::_slider pic 2 ≠ "" ] Set variable [ $_filename; value: "slider_2" & characterRight ( Server::_slider 2 imgPath ; 4 ) ] Export all field values [ Server::_slider pic 2; "file:html/images/slider/$_filename" ] Set variable [ $_slider; value:$_slider & "/>¶" ] End (if)
Important individual steps can then also be commented on. Comments should help and not confuse. There is no point in commenting meticulously on every script step, as this disrupts the flow of the source text enormously. In any case, comments, when used correctly, are an important tool for ensuring an overview of FileMaker solutions even years later.
Author: Jens Liebelt
Liebelt Polaris specialist components
Main street 23
21646 Holvede
- FileMaker databases
- Dynamic websites with FileMaker
- E-commerce with FileMaker
- FileMaker as NewsBlog System
- FileMaker distance learning, with free time management
- FileMaker Support via TeamViewer
