The function returns the following error codes:
0 ... everything is OK, the data has been saved -1 ... nothing to save, the workspace is empty