View Full Version : Lscripters: Is this useful to you? (MsgBox dialog include script)

07-04-2011, 12:21 AM
Just messing around making utilities that help me with my scripts and wanted something better than info() or warning() - something more along the lines of a typical operating system dialog box. So I made MsgBox.ls which codes like this:

// at the beginning of your script
@insert "MsgBox.ls"
// Then anywhere in your code
if (MsgBox(int_MsgBoxType, str_MessageText, str_TitlebarText))
// user pressed OK on our MsgBox

/** Parameters:

int_MsgBoxType = one of these for the icon type: MSG_INFO, MSG_QUES, MSG_WARN, MSG_CRIT, MSG_OK, MSG_CANCEL
str_MessageText = a string which can contain html bold and line break tags like this: "<b>this is bold</b><br>this is on a new line"
str_TitlebarText = a string for the dialog's title caption - though a nil or empty string here will give the default text for the dialog type (i.e. "Information", "Critical" etc)


It handles all the requester stuff, embeds the icons into the script, and auto-sizes the requester based on the message length. Plus it has bold text and manual line breaks via <b></b> and <br> tags. It returns true if the person pressed OK and false if they pressed Cancel.

This is what it can look like:


Let me know if anyone is interested, I'll just clean it up comment-wise and upload it here. It might save you a bit of trouble and make your dialog boxes stand out a touch from that sea of grey in the interface.

07-04-2011, 02:33 AM
cool stuff sami

07-04-2011, 11:09 AM
Nice. I'm interested!

07-04-2011, 09:21 PM
MsgBox v1.0 download

Here it is in case anyone wants it. There are 2 scripts in here. The main script to be inserted (included) into your script (either Layout or Modeler) and a Test script which shows you roughly how the thing works.

Another example of the MsgBox:


And here's the interface of the test script:



Add special symbols and other characters as bold chars - it may crash if you send it foreign symbols beyond ASCII 128 etc.
Add parameter for customizable MAX_WIDTH - currently this is at 80 characters
Fix Auto-wrap to be word-based or syllable-based - currently wrapping is only character-based so you must insert your own line breaks (with the br tag) to get it to look nicest.
Add the ability to have a custom icon (actually this exists currently, but is not overtly exposed since I haven't debugged that part yet)
Add justification styles to text block
Integrate this with my SuperText text drawing utility for requesters. See here (http://www.newtek.com/forums/showthread.php?t=10358&highlight=supertext) for what it does - I'm trying to locate my original source from years ago - I only seem to have my compiled LSC version of it.

Hope it's useful. Enjoy! (and feel free to tell me where my code sucks)

07-04-2011, 09:56 PM
Thanks! :thumbsup:

07-05-2011, 03:51 AM
Gangsta lorem ipsum is my go-to lorem ipsum, too.

07-05-2011, 04:08 AM
Nice work and generous sharing. Thanks!

07-05-2011, 05:45 PM
cool. Hope it's useful. :)