• Solutions
    • FERC XBRL Reporting
    • FDTA Financial Reporting
    • SEC Compliance
    • Windows Clipboard Management
    • Legato Scripting
  • Products
    • GoFiler Suite
    • XBRLworks
    • SEC Exhibit Explorer
    • SEC Extractor
    • Clipboard Scout
    • Legato
  • Education
    • Training
    • SEC and EDGAR Compliance
    • Legato Developers
  • Blog
  • Support
  • Skip to blog entries
  • Skip to archive page
  • Skip to right sidebar

Friday, January 19. 2018

LDC #68: Application Shutdown Script

Way back in LDC #39, we discussed the file “ApplicationInitialize.ls” and how any script functions in it are run at application startup. With GoFiler 4.21b’s release on January 16, 2018, we’ve added support for a similar file, “ApplicationShutdown.ls”. As the name suggests, this file is called when GoFiler shuts down. This is a pretty powerful feature because it lets you do things to “clean up” your environment if you’ve modified it with other scripts or if you want to return the system to a desired state after using the application.


In another blog post (LDC# 42), we discussed a script that could unregister GoFiler. With the new ApplicationShutdown file, we can set that to automatically trigger after the application exits. This way, GoFiler will automatically release its license after closing, so another user can open it on a different machine. This is very useful in production environments with multiple shifts using different computers, where you may have more than one user sharing a key. It also could be handy in an environment where you switch between desktop and laptop computers to work. The drawback here is that GoFiler will require an internet connection to open or close successfully with this script running, but that’s very rarely an issue. Here’s our modified script:



#define                 BAT_NAME                "RegisterGF.bat"
#define                 TIMEOUT                 "timeout /t 3 /nobreak > nul\r\n"

int main() {

    string              temp_folder;                                    /* temp folder                          */
    string              gofiler;                                        /* path to GoFiler                      */
    string              bat_contents;                                   /* contents of bat file                 */
    string              bat_file;                                       /* location of bat file                 */
                                                                        /*                                      */
    gofiler = "\""+AddPaths(GetApplicationExecuteFolder(),              /* path to GoFiler                      */
      "GoFiler.exe\"");                                                 /*                                      */
    bat_contents = TIMEOUT;                                             /* add a sleep to bat file              */
    bat_contents += gofiler+ " /NoGUI /unregister -silent\r\n";         /*                                      */
    temp_folder = GetTempFileFolder();                                  /* get temp folder                      */
    bat_file = AddPaths(temp_folder, BAT_NAME);                         /* get full path to bat file            */
    StringToFile(bat_contents,bat_file);                                /* write out bat file                   */
    RunProgram("cmd.exe", "/C \""+bat_file+"\"");                       /* run the bat file                     */
    return ERROR_NONE;                                                  /* return                               */
    }


This is a very simple script with only one function, main. The script processor calls it after the application frame has closed. It writes out a batch file named “RegisterGF.bat” and then runs it. This isn’t complicated, and it gets the job done. As mentioned above, the ins and outs of this script are described in detail in the previous blog post. We’ve just refactored it slightly to work as a cleanup script instead of as part of a menu function.


When using the ApplicationShutdown file to wind down your application, the important thing to keep in mind is that not all Legato functions will work in this setting. The application frame has closed by this point, so you will not have access to things like Edit Windows, Edit Objects, etc. Message boxes work, but they will not have the full functionality that they normally do when used as part of a script. The idea behind the shutdown script is more to put the system back to a known state, so these objects shouldn’t be needed anyway. Core functionality, like file I/O, HTTP GET/POST requests, and ODBC connectivity, still function as expected.


The example given is obviously very basic, but much more complex uses aren’t hard to imagine. For example, a script solution could be written to handle checking in or out files from a revision control system. When a user closes the application, it could be set up to automatically release any locks or check back in any files that the user may have held. With the ability to manipulate the file system, connect to databases, and communicate with web pages, there are a lot of ways running Legato scripts on application shutdown can be integrated into a system.


 


Steven Horowitz has been working for Novaworks for over five years as a technical expert with a focus on EDGAR HTML and XBRL. Since the creation of the Legato language in 2015, Steven has been developing scripts to improve the GoFiler user experience. He is currently working toward a Bachelor of Sciences in Software Engineering at RIT and MCC.

Additional Resources

Novaworks’ Legato Resources

Legato Script Developers LinkedIn Group

Primer: An Introduction to Legato 



Posted by
Steven Horowitz
in Development at 14:55
Trackbacks
Trackback specific URI for this entry

No Trackbacks

Comments
Display comments as (Linear | Threaded)
No comments
Add Comment
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

 
   
 

Quicksearch

Categories

  • XML Accounting
  • XML AICPA News
  • XML FASB News
  • XML GASB News
  • XML IASB News
  • XML Development
  • XML Events
  • XML FERC
  • XML eForms News
  • XML FERC Filing Help
  • XML Filing Technology
  • XML Information Technology
  • XML Investor Education
  • XML MSRB
  • XML EMMA News
  • XML FDTA
  • XML MSRB Filing Help
  • XML Novaworks News
  • XML GoFiler Online Updates
  • XML GoFiler Updates
  • XML XBRLworks Updates
  • XML SEC
  • XML Corporation Finance
  • XML DERA
  • XML EDGAR News
  • XML Investment Management
  • XML SEC Filing Help
  • XML XBRL
  • XML Data Quality Committee
  • XML GRIP Taxonomy
  • XML IFRS Taxonomy
  • XML US GAAP Taxonomy

Calendar

Back May '25 Forward
Mo Tu We Th Fr Sa Su
Sunday, May 18. 2025
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Feeds

  • XML
Sign Up Now
Get SEC news articles and blog posts delivered monthly to your inbox!
Based on the s9y Bulletproof template framework

Compliance

  • FERC
  • EDGAR
  • EMMA

Software

  • GoFiler Suite
  • SEC Exhibit Explorer
  • SEC Extractor
  • XBRLworks
  • Legato Scripting

Company

  • About Novaworks
  • News
  • Site Map
  • Support

Follow Us:

  • LinkedIn
  • YouTube
  • RSS
  • Newsletter
  • © 2024 Novaworks, LLC
  • Privacy
  • Terms of Use
  • Trademarks and Patents
  • Contact Us