Scripting
The CODESYS scripting engine is extended with functions by CODESYS File-Based Storage which can be used in a script to open a file-based project, to convert a project to the file-based storage format, and to validate a project before conversion. The scripting functionality is available only when the CODESYS File-Based Storage plug-in is installed.
fbs: Entry point for file-based storage operationsFBSValidationStatus: List of validation states
Opening a project (fbs.open)
Use fbs.open to open a file-based project or a workspace.
project = fbs.open(path, primary=True, update_flags=VersionUpdateFlags.NoUpdates, index=-1)
| Path to the project folder or to a workspace file ( |
| If The default value is |
| Version update flags which control whether or not the libraries and compiler version are updated when the project is opened. The default value is |
| Index of the project to be opened when |
Return value: The function returns the open project.
Converting a project (convert_to_fbs)
Each project object is extended with the convert_to_fbs method. This method is available only when the CODESYS File-Based Storage add-on is installed.
success = project.convert_to_fbs(path, native_import_handler, update_flags=VersionUpdateFlags.NoUpdates)
| Destination directory for the converted project |
| Import handler which is used during the conversion |
| Version update flags which are applied when opening the converted project. The default value is |
Return value: When the conversion is successful, True is returned. During the conversion, the source project is closed and a new, empty file-based project is opened as the primary project.
Validating a project (validate_for_fbs)
Use validate_for_fbs to check a project for problems before conversion.
results = project.validate_for_fbs()
When there is no problem, an empty list will be returned. Otherwise, a list of validation results will be returned. Each result has the following properties:
| Status of the result of type |
| Description of the problem |
| Object to which the problem refers |