Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter SeventeenApplication Integration Functions (continued)

17.3 Application Shutdown

17.3.1 Shutdown Process

When the application shuts down, a script can be run to wind down certain user operations. This script is only run after a normal GUI exit.

The post process checks for the file “ApplicationShutdown.ls” in the application “Scripts” folder. If it is not present the application closes. The script file is not supplied as part of the application standard install.

At the point of script entry, all background processes have been terminated, all script hooks shutdown, all windows will have been closed and with the exception of certain internal static classes, all modules shutdown. What this means is certain operations may not be possible upon entry tot he script. For example, opening a file in an edit window or running a menu command is not possible.

17.3.2 Creating a Shutdown Script

The shutdown script can be a simple implied entry script or employ a ‘main’ entry function. If the script encounters a preprocess or runtime error, a message box will be displayed by the application indicating an error. Check the application log for error details.

Shutdown scripts are useful at unwinding operations that are currently in progress, or integrating into other systems to enable better control over who is using the application and where. Functions like ODBC connectivity, File I/O, and HTTP Get/Post requests are still available, so Legato still has the ability to communicate with external applications. Below is an example shutdown script, written for GoFiler Complete:

int main() {

    string              temp_folder;
    string              gofiler;
    string              bat_contents;
    string              bat_file;

    gofiler = "\""+AddPaths(GetApplicationExecuteFolder(),
      "GoFiler.exe\"");
    bat_contents = "timeout /t 3 /nobreak > nul\r\n";
    bat_contents += gofiler+ " /NoGUI /unregister -silent\r\n";
    temp_folder = GetTempFileFolder();
    bat_file = AddPaths(temp_folder, "RegisterGF.bat");
    StringToFile(bat_contents,bat_file);
    RunProgram("cmd.exe", "/C \""+bat_file+"\"");
    return ERROR_NONE;
    }

This script writes out a batch file to the user’s temporary files directory, then executes the batch file before the application closes. The batch file itself simply waits for 3 seconds, then runs GoFiler Unregister command in No GUI mode, with the silent flag set. This effectively unregisters the application from our server so the key is able to be used on a different machine. This is useful in production environments that require switching the license from one user to the other at the end of a shift.