Some really crazy people may agree that
Code: Select all
MESSAGEBOX "Hello !"
Code: Select all
#IF Defined(__FB_WIN32__)
#include "windows.bi"
MessageBox(0, "Hello !", "", 0)
#ElseIf Defined(__FB_LINUX__)
...
Draft:
MESSAGEBOX <String text>[, <String title>][, <ENUM flags>[, <String buttons>]], <ByRef ENUM returnvalue>
(assuming int beeing "returnvalue", not "flags" if parameter list is string(, string), int)
Flags for icons(sounds) and standard buttons => NONE, ALERT, QUESTION, INFO, STOP, ERROR; OK, OKCANCEL, YESNO, SAVE, RETRY... Further, you may label buttons on your own. Ideally, the message box is fully integrated in the platform's GUI and its look&feel. But it might also enhance the GUI by adding new standard options like "Save"/"Don't Save"/"Cancel". The strings are UTF-8 encoded, line break code is 13 (\r), support of soft-hypen and automatic linewrap.
The button string is e.g. "Left|Up|Down|Right", e.g."R_ight" defines (and might show) R as a hotkey. (no need to implement everything, just regard => remove underscores) Return value is 0 to 4, almost normally depending on the button's number. If the platform thinks, "Okay" should come after "Cancel", it will be, but the return values are always the same. You can specify a default value (hit Return) by setting the return value to the button number resp. its return value. In user-defined buttons you can further use " _" at the beginnig for Return(default button) as hotkey, "0_" for Escape. Such codes will be hidden. As default, also "1"-"4" are hotkeys for the buttons.
Standard return values:
0 - CANCEL, ABORT [CLOSED?]
1 - NO, RETRY, DONTSAVE [BUTTON1?]
2 - SAVEALL, IGNORE [BUTTON2?]
3 - OK, YES, SAVE [...]
User-defined buttons simply return 1-4 for the respective button. 0 is false, 3 is binary "11" and therefore most like true. 0 could also be returned on error / closing the dialog window.
flags (ENUM DIALOGFLAG):
32 ALERT, 64 STOP, 96 QUESTION, 128 INFO, 224 ERROR
0 "OK" (NONE / OKONLY)
1 OK Cancel (OKCANCEL)
2 Yes No (YESNO)
3 Yes No Cancel (YESNOCANCEL)
4 Save Don't_Save (SAVEDONTSAVE)
5 Save Don't_Save Cancel (SAVECANCEL)
7 "Cancel" (CANCELONLY)
8 Save Save_All (SAVEALL)
9 Save Save_All Cancel (SAVEALLCANCEL)
12 "Retry" (RETRYONLY)
13 Retry Abort (RETRYABORT)
14 Retry Abort Ignore (RETRYIGNORE)
The return values should be also part of the DIALOGFLAG type, therefore "OK" is named "OKONLY" for instance.
You might also have a waiting dialog and progress-bar dialog, but the message box and fileselect-dialog are elementary for a BASIC like FreeBASIC.