So far in this blog, we’ve mentioned a couple of ways that Legato can improve or replace existing functionality and add new features entirely to GoFiler through the use of hooks that can happen pre- or post-process on a GoFiler function or by hooking a script to custom menu items. Now we’ll talk about a third method of enhancing GoFiler’s functionality.
Friday, November 18. 2016
The AddFrameInitializeFunction hook runs a script on application startup. This lets you customize what functions GoFiler runs automatically when it starts.
When GoFiler starts, it initializes and runs things in a very specific order. That initialization order is:
- Scripts added using AddFrameInitializeFunction
- Command Line Actions (second processing)
- News RSS Feed Run
- Crash File Recovery Process
- Dashboard Processing
- Error Report Upload Request
- User Account Control Edit
- Application “First Run” Actions
AddFrameInitializeFunction takes four parameters, only one of which is required. The function signature is (optional parameters are written in brackets):
The parameters are defined as:
An optional word that specifies the priority order of the script. This allows scripts/calls to be ordered in the manner in which they are executed. If omitted, the script is set to the bottom priority.
A string containing the name of the script to run. If name is empty, the script calling the AddFrameInitializeFunction is used. If a root path is not provided, the calling script’s path is used as a basis for the filename.
An optional string containing the name of the function in the script file to run. If omitted or empty, the default entry point is located and run.
Zero or more optional parameters to pass to the script. Variables cannot be passed by reference. When parameters are employed, the function parameter must be provided. However, it can be a simple "" empty string. Handles cannot be passed. The parameter string should be formatted like “variable1 : value1; variable2 : value2”.
This all sounds well and good, but what can you actually do with this? It’s a bit outside the scope of this post to provide the code for how these could be implemented, but in general terms I’ll talk about three ways you could use a function like this to perform powerful tasks and achieve different goals.
1. Authenticate Users
GoFiler can hold some sensitive information, like client names, CIKs, CCCs, etc., and can let a user file documents to the SEC. This data and functionality is definitely something you would want to protect from unauthorized access. The Collaboration functions in GoFiler can lock individual pieces of the application behind a password or Windows authentication, but what if you want to lock the entire application so that it cannot be run unless by an authorized user?
That’s where this type of hook can come it. To authenticate a user on application startup, you would want to write a script that asks for a username and password. It could do something simple like checking the provided username and password against something hard coded into the script (this wouldn’t be very secure, as someone could open the script file to see the password!) or something more complex. A more secure method of authenticating a user on startup would be to set up an ODBC connector to a database and use a SELECT statement to retrieve the user ID of someone with the same username and password. If no ID is returned, then the login failed. You could also use HTTPPost to POST the username and password to a website, which could handle authentication, and respond back if the user is valid or not.
You could execute any of these scripts when the application is run to authenticate a user. Anyone logging onto a workstation that can access GoFiler would then have to verify their identity before using the software to add an additional layer of security.
2. Automatically Update Templates
GoFiler supports a lot of user templates. For more information, see our previous blog post, Customizing GoFiler Through Templates. If you’re using these customizable templates, and have multiple installations of GoFiler in your environment, it can be difficult to make sure that all of your users are always using the most recent versions of the templates. You can automate the update process by having a Legato script run on application startup.
To do this, I would first suggest keeping all of your templates, along with a file called “version.ini” or something similar, in a Templates folder on a shared directory. On application startup, GoFiler could use the SDK function GetParameter to get the version number out of the INI file on the network and compare it to a version number it stores itself. If these two version numbers match, great, you’re done and the application starts as normal. Otherwise, the script would then copy all of the template files out of the Templates folder on the network drive using the CopyFile SDK function, which overwrites any files that have the same name in the target directory. If you wanted to get fancy, or you have a lot of template files, you could use the ProgressOpen SDK function to create a progress bar as it updates, so users will see that the application is doing something (copying files) instead of just taking a long time to start up.
3. Create Custom Wizards/Walk-Throughs
If you have a very specific workflow process at your organization, you can modify GoFiler to prompt the user for inputs and guide them through the process. For example, let’s say you have a user who only prepares Section 16 filings. When GoFiler starts up, you could have a dialog window automatically open, which would ask the user if they are creating a new Form 3, 4, or 5. It could then ask the user if they want to use an existing data file or start from scratch. The script could then automatically create a project file, create an XML data file, attach the data file to the project file, auto-fill in some fields, and generally just guide the user to where you want them to be. It could automate saving/creating files and folders. These are all things users can do themselves but actively guiding the user through the steps of a process reduces training time, removes a lot of ambiguity in how the software works, and streamlines your workflow.
This idea could be adapted to pretty much anything; the UI on startup could ask the user what task they are doing and then run them through a predefined wizard for each and every task the user does.
These are just a couple of examples as to how you can use the AddFrameInitializeFunction SDK function to customize GoFiler on startup. You can do a lot more with this, from changing the name of the application (if you want to call it My Fancy SEC Software instead of GoFiler Complete, you can absolutely do that with this hook combined with the SetApplicationName function) to pulling data from databases and setting up a customized user environment at the start of each session. The end goal here is to allow you to customize the application to suit your company’s needs, and this function is a great place to start.
|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.|