wxBasic
Find sources: "WxBasic" – news · newspapers · books · scholar · JSTOR (November 2014) (Learn how and when to remove this message)
| wxBasic | |
|---|---|
| Developer | David Cuny |
| Initial release | 2002; 23 years ago (2002) |
| Stable release | |
| Operating system | Cross-platform |
| License | GNU Lesser General Public License |
| Website | wxbasic |
wxBasic is a free software / open-source software, cross-platform BASIC interpreter. As it is based on syntax of the BASIC language, it is designed to be simple to learn and understand, and allow novice programmers to write applications for graphical environments like Windows and Linux with minimal effort. wxBasic is a bytecode based language, like Perl or Java. It is licensed under the LGPL, so proprietary software's source code can be linked against it.
It can create stand-alone executables by binding together source code with the interpreter. In contrast with executables created by similar commercial programs like Visual Basic, executables produced by wxBasic do not require any external DLL file, resource file, or installer to run. The executable is distributed alone and can be run immediately by end-users. As with programs written in any interpreted language, wxBasic programs may also be run straight from the source code on any platform, if wxBasic is present.
wxBasic is written primarily in C, with some C++ linking it to the wxWidgets library. wxWidgets supplies the cross-platform features. It runs on Microsoft Windows using native controls, and on Linux and macOS using the GTK+ library.[2] wxBasic is also the basis for the SdlBasic project.
Example
[edit ]The following program implements a text viewer:
' from https://wxbasic.sourceforge.net/phpBB2/viewtopic.php?t=554 ' Simple Text Viewer written in wxBasic dimAppName="Text Viewer" fileName="" ' Main window dimframe=newwxFrame(Nothing,-1,AppName&" - Untitled Document") ' Text edit control dimcontrol=newwxTextCtrl(frame,-1,"",wxPoint(0,0), wxSize(100,100),wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH) ' Status bar - The one at the bottom of the window dimstatus=frame.CreateStatusBar(1) frame.SetStatusText("Ready") ' ' Dialog used for Open dimfileDialog=newwxFileDialog(frame) ' ' add menubar to the frame dimmBar=newwxMenuBar() frame.SetMenuBar(mBar) ' ' build the "File" dropdown menu dimmFile=newwxMenu() mBar.Append(mFile,"&File") ' make it ' mFile.Append(wxID_OPEN,"&Open...","Loads an existing file from disk") ' mFile.AppendSeparator() mFile.Append(wxID_EXIT,"E&xit\tAlt-X","Exit Application") SubonFileOpen(event) fileDialog.SetMessage("Open File") fileDialog.SetStyle(wxOPEN) IffileDialog.ShowModal()=wxID_OKThen fileName=fileDialog.GetPath() Ext=fileDialog.GetFilename() control.Clear() control.LoadFile(fileName) frame.SetTitle(AppName&" - "&fileName) frame.SetStatusText(Ext) EndIf EndSub ' Connect(frame,wxID_OPEN,wxEVT_COMMAND_MENU_SELECTED,"onFileOpen") SubonFileExit(event) frame.Close(True) EndSub ' Connect(frame,wxID_EXIT,wxEVT_COMMAND_MENU_SELECTED,"onFileExit") ' build the "Help" dropdown menu dimmHelp=newwxMenu() mBar.Append(mHelp,"&Help") mHelp.Append(wxID_HELP,"&About\tF1","About this program") ' SubonHelpAbout(event) Dimmsg="Text View allows any text file\n"& "to be viewed regardless of its extension.\n"& "If the file being opened isn't a text file\n"& "then it won't be displayed. There will be a\n"& "little garbage shown and that's all." wxMessageBox(msg,"About Text View",wxOK+wxICON_INFORMATION,frame) EndSub Connect(frame,wxID_HELP,wxEVT_COMMAND_MENU_SELECTED,"onHelpAbout") frame.Show(True)
References
[edit ]- ^ a b "News, November 2016". wxbasic.net. Retrieved 25 September 2017.
- ^ "Download". wxbasic.net. Retrieved 25 September 2017.