• 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 27. 2017

Legato Developers Corner #19: Message Boxes

Whenever you are writing a script, getting information to and from users is always a very important (and often complicated) part. There needs to be a way to notify the user that something has happened or to ask a user a simple question. Legato provides a basic interface for performing these tasks using message boxes.


The sample script provided in this blog showcases a number of the message boxes available in Legato. In the blog itself, we’ll focus more on how message boxes work and the types of message boxes you can use.


Our Sample Script:


int         rc;
int         remember;
string      text;

int main() {
    rc = MessageBox('i', "We are using Legato to create a message box.");

    if (rc == IDOK) {
      MessageBox('i', "You pressed OK.");
      }

    if (rc == IDCANCEL) {
      MessageBox('i', "You pressed the X.");
      }

    rc = YesNoRememberBox("Do you want to continue?");
    remember = GetLastError();
    if (rc == IDNO) {
      text = "Okay, we'll stop now!";
      if (remember != 0) {
        text += " You wanted to remember this.";
        }
      MessageBox('x', text);
      }
    if (rc == IDYES) {
      text = "Good Answer.";
      if (remember != 0) {
        text += " You wanted to remember this.";
        }
      MessageBox(text);
      }
    if (rc == IDCANCEL) {
      MessageBox('x', "Operation cancelled!");
      return rc;
      }
    return ERROR_NONE;
    }

A screenshot of a message box created with LegatoThe Legato MessageBox SDK function displays a message box. Each message box works the same basic way. The function returns an int value containing an error code or standard Windows ID code, which corresponds to the choice the user made. The most common return codes are standard defines in Legato: IDOK, IDYES, IDNO, and IDCANCEL. These let you quickly and easily determine what the user’s response to your message box was. If the user pressed the “no” button, then the response back will be IDNO. If they closed the box by clicking the X in the upper right corner, the response will be IDCANCEL. If they click a cancel button, the response will also be IDCANCEL.


Depending on the type of message box, you may be able to define a character that represents what icon shows up in the upper left of the box. In the MessageBox function, for example, the first parameter takes either an integer or a character that defines what type of icon you’d like in the top left. The acceptable values are:



Definition   Character   Type
  MB_INFO   ‘I’   Information
  MB_NONE   ‘N’   None (No Icon)
  MB_QUESTION   ‘Q’   Question
  MB_STOP   ‘S’   Stop
  MB_EXCLAMATION   ‘X’   Exclamation

You may also want to remember the user’s input to avoid asking them again. Functions that support this will have the suffix “Remember” in their name. For these functions, the value of the checkbox will be stored as the last error. You can access that error by using the GetLastError function. So, to get the value of a checkbox, the code would look like this:


    rc = YesNoRememberBox("Do you want to continue?");
    remember = GetLastError();

Remember that you need to use the GetLastError function immediately after your message box function call to avoid accidentally overwriting the last error with a subsequent function’s error value. The returned value from the remember boxes also uses the IDYES to signify that the box was checked. To test for it, you need to check if the variable remember was set to IDYES. You can store this value in an INI file using the PutSetting function. Note that this function will not remember if a user cancelled the message box by clicking the X button.


This is a list of all of the types of message box functions offered by Legato:


Function   Supports Icon   Notes
  MessageBox   Yes   Basic message box to display info to user. Has OK button.
  OKCancelBox   Yes   Displays message. Has OK and Cancel buttons.
  YesNoBox   Yes   Displays message. Has Yes and No buttons.
  YesNoCancelBox   Yes   This box is programmatically identical to the YesNoBox, except it has an explicit cancel button instead of the user having to press the X to cancel.
  YesNoRememberBox   No   Displays message, has Yes and No buttons, and has a “Remember” checkbox. Value from checkbox can be accessed by using the GetLastError function immediately after this function is called.
  YesNoCancelRememberBox   No   Programmatically identical to the YesNoRememberBox, but it has an explicit cancel button.

In summary, message boxes are a very easy way to add some quick UI to your script. Legato is capable of more complicated custom dialog boxes as well, but that is a topic that will be covered in a different blog post.




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 11:48
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
Monday, May 19. 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