Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

XL.Initialize

Initializes the XL library by loading it.

Component Version macOS Windows Linux Server iOS SDK
XL 2.9 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "XL.Initialize"; LibPath { ; LicenseName; LicenseKey } )   More

Parameters

Parameter Description Example Flags
LibPath Native path to the DLL on Windows or Dylib file on MacOS.
Can be empty for default file name with file in same folder as plugin.
"C:\libxl\libxl.dll"
LicenseName The name of your libXL license. "" Optional
LicenseKey The license key of your libXL license. "" Optional

Result

Returns OK on success.

Description

Initializes the XL library by loading it.
You can keep the library in a database field and export it at runtime to a known location and load it from there.
If you have no license yet, you can test this function by passing empty strings for name and key. If you have a license key, please pass it and we store it for unlocking the library later when loading/creating a book.

For getting a license key, please visit the libXL website:
https://www.monkeybreadsoftware.com/filemaker/libxl.shtml

Starting with version 4.4, you can pass just the filename of library and the plugin finds it in the Extensions folder or in FileMaker's application folder.

Windows error 193 means that 64-bit FileMaker tried to load 32-bit library or 32-bit FileMaker tried to load 64-bit library. The bit level must match between app and library. For macOS the error message will tell you about wrong architecture.

Starting version 9.5, the plugin will look into the same folder for the DLL as the plugin resides. And we still look for 32/64 suffixes to DLL name. If no name is provided, we look for libxl.dll/dylib/so files.

If you get a crash here on MacOS, please check if crash report says Code Signature Invalid. Then you may need to code sign the dylib yourself to match the code signature of your runtime application. The dylib from MBS is normally code signed already and should work as is.

Troubleshooting:
  • If you get error 193 on Windows, you may have the wrong architecture. e.g. you got 32-bit, but you need 64-bit or vice versa.
  • If you got a libxl.dylib on macOS, that is no code signed, you will get back an error message, that the file is not allowed to load (disallowed by OS policy).
  • If you got a libxl.dylib on macOS, that is not notarized, you may see a gate keeper dialog telling you the library was not searched for malware and the file can't be loaded (disallowed by OS policy).
  • If you got a libxl.so or libxl.dylib for the wrong CPU architecture, the function will return an error with e.g. saying you need x86, but have arm code or vice versa.
  • if you managed to load a libxl.dylib with a broken code signature, you may see a crash when the plugin calls CreateBook function reporting a broken code signature.
  • If the file path is wrong, the macOS and Linux plugins report an error message about that. On Windows you may just get error 126, which means "module not found".
  • If the file is shorted than expected on macOS, you get an error with a message like this: slice 1 extends beyond end of file.
  • If you overwrite the libxl.dylib file after loading it, you may get crashes with broken code signature, if old and new file are not identical.

This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.

Examples

Initialize XL:

MBS( "XL.Initialize"; "/Library/FileMaker Server/Extensions/libxl.dylib"; "Test User"; "mac-43567890..." )

Initialize when needed:

#Initialize XL
If [MBS( "XL.IsInitialized" ) ≠ 1]
    If [Get ( SystemPlatform ) = -3]
        # iOS
        Exit Script []
    Else If [Get ( SystemPlatform ) = -2]
        # Windows
        Set Variable [$path; Value: "libxl.dll"]
        Set Variable [$key; Value: "win-32213..."]
    Else
        # Mac
        Set Variable [$path; Value: "libxl.dylib"]
        Set Variable [$key; Value: "mac-32213..."]
    End If
    Set Variable [$r; Value: MBS( "XL.Initialize"; $path; "test"; $key )]
    If [$r ≠ "OK"]
        Show Custom Dialog [ "LibXL failed to initialize"; $r]
    End If
End If

Initialize with license key on Windows with Server:

MBS( "XL.Initialize"; "C:\Program Files\FileMaker\FileMaker Server\Database Server\Extensions\libxl.dll"; "Test User"; "win-43567890..." )

Initialize automatically and look in same folder as plugin for the DLL/dylib/so file:

MBS("XL.Initialize"; ""; $LicenseName; $LicenseKey)

Register LibXL for MBS Plugin

If [ MBS("XL.IsInitialized") ≠ 1 ]
      If [ MBS("IsMacOS") ]
            Set Variable [ $r; Value: MBS( "XL.Initialize"; $path; "xxx"; "mac-xxx" )]
      Else If [ MBS("IsWindows") ]
            Set Variable [ $r; Value: MBS( "XL.Initialize"; $path; "xxx"; "win-xxx" )]
      Else If [ MBS("IsLinux") ]
            Set Variable [ $r; Value: MBS( "XL.Initialize"; $path; "xxx"; "linux-xxx" )]
      Else If [ MBS("IsIOS") ]
            Set Variable [ $r; Value: MBS( "XL.Initialize"; $path; "xxx"; "ios-xxx" )]
      Else
            Set Variable [ $r; Value: "new platform?" ]
      End If
      If [$r ≠ "OK"]
            Show Custom Dialog ["Problem with LibXL Registration"; $r]
      End If
End If

Init with automatic picking of library name:

MBS( "XL.Initialize"; ""; ""; "" )
// looks for libxl library in plugin folder.

See also

Release notes

  • Version 14.3
    • Added check to XL.Initialize and DynaPDF.Initialize to return an error if the license key includes invalid characters like a space character.
  • Version 14.1
    • Added check to LibXL.Initialize to return error if you use the license key for a different platform.
  • Version 11.2
    • Changed XL.Initialize to accept empty path and pick the file name automatically per platform.
  • Version 9.5
    • Changed DLL loading for DynaPDF.Initialize and XL.Initialize functions to look for given DLL path, try 32/64 DLLs. If only file name is given, we look into plugin folder, too. If no file name is given, we try default file name.
  • Version 8.0

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 25th October 2023


XL.Format.SetWrap - XL.IsInitialized