"How does AppStudio's NSB.MsgBox work?"


AppStudio’s NSB.MsgBox is a function provided by NS Basic/App Studio, a development tool for creating mobile and desktop apps using JavaScript. NSB.MsgBox is used to display a message box or a dialog box to the user.
Here’s how NSB.MsgBox works:

  1. Syntax: NSB.MsgBox(message, buttons, title, callback)
  2. message (required): The message to be displayed in the message box. It can be a string or HTML content.
  3. buttons (optional): Specifies the buttons to be displayed in the message box. It can have one of the following values:
  • NSB.OK: Displays only an OK button.
  • NSB.OKCANCEL: Displays OK and Cancel buttons.
  • NSB.YESNO: Displays Yes and No buttons.
  • NSB.YESNOCANCEL: Displays Yes, No, and Cancel buttons.
  1. title (optional): The title or caption of the message box.
  2. callback (optional): A callback function that is executed when the user clicks a button in the message box. It receives the button clicked as the argument.
  3. Example: javascript NSB.MsgBox("Hello, World!", NSB.OK, "Greeting", function(button) { if (button === NSB.OK) { console.log("User clicked OK"); } });

In this example, a message box is displayed with the message “Hello, World!”, an OK button, and a title “Greeting”. When the user clicks the OK button, the callback function is executed, and the button value is checked to perform further actions.

Note that NSB.OK, NSB.OKCANCEL, NSB.YESNO, and NSB.YESNOCANCEL are predefined constants provided by NS Basic/App Studio to specify the button options.

  1. Return Value: The NSB.MsgBox function does not return a value directly. Instead, it invokes the callback function with the button value that the user clicked. This allows you to handle the user’s selection and perform appropriate actions based on the button clicked.

Overall, NSB.MsgBox provides a simple way to display user-friendly message boxes or dialog boxes in NS Basic/App Studio applications and allows you to interact with the user’s input through the callback function.