LM.GUI Functions

The following functions are defined in the LM.GUI namespace. To call one of these functions, be sure to prepend

LM.GUI.
to the function's name. For example,
LM.GUI.OpenFile()
is valid, while
OpenFile()
is not complete.


string OpenFile(caption)

Prompts the user to select a file to open. Returns the path name of the selected file as a string. If the user cancels the file dialog, the function returns an empty string, "".

caption (string): a string to use as a caption in the file dialog
Return value (string): path name of the selected file

string SaveFile(caption)

Prompts the user to select a file to save. Returns the path name of the selected file as a string. If the user cancels the file dialog, the function returns an empty string, "".

caption (string): a string to use as a caption in the file dialog
Return value (string): path name of the selected file

int Alert(alertType, label1, label2=nil, label2=nil, label3=nil, button1="OK", button2=nil, button3=nil)

Presents the user with an alert box. With this function, you can specify up to three lines of text and three buttons, or just a single line of text with an OK button. If any of the text labels or buttons are nil, then that item will not appear in the alert box. After the user clicks a button in the laert box, the function returns 0, 1, or 2, depending if the user pressed button 1, 2, or 3.

alertType (int): a constant indicating the type of alert box
label1 (string): the first line of text to display
label2 (string): the second line of text to display (defaults to nil)
label3 (string): the third line of text to display (defaults to nil)
button1 (string): the first button's label (defaults to "OK")
button2 (string): the second button's label (defaults to nil)
button3 (string): the third button's label (defaults to nil)
Return value (int): number of the button that the user pressed
extern char *LM_OpenFileDialog @ OpenFile(const char *caption);
extern char *LM_SaveFileDialog @ SaveFile(const char *caption);
 
/*** Alert Box ***/
 
#define LM_ALERT_INFO @ ALERT_INFO
#define LM_ALERT_WARNING @ ALERT_WARNING
#define LM_ALERT_QUESTION @ ALERT_QUESTION
 
extern int LM_DoAlert @ Alert(int alertType,
             const char *str1, const char *str2 = NULL, const char *str3 = NULL,
             const char *but1 = "OK", const char *but2 = NULL, const char *but3 = NULL);