WxBasic
Encyclopedia
wxBasic is a free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

 / open-source software
Open-source software
Open-source software is computer software that is available in source code form: the source code and certain other rights normally reserved for copyright holders are provided under a software license that permits users to study, change, improve and at times also to distribute the software.Open...

, cross-platform
Cross-platform
In computing, cross-platform, or multi-platform, is an attribute conferred to computer software or computing methods and concepts that are implemented and inter-operate on multiple computer platforms...

 BASIC interpreter
Interpreter (computing)
In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language...

. As it is based on the easy-to-use syntax of the BASIC language, it is simple to learn and understand, allowing even novice programmers to write nice-looking applications for graphical environments like Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 and Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 with minimal effort. As of September, 2004, the software is in a beta
Development stage
A software release life cycle refers to the phases of development and maturity for a piece of computer software—ranging from its initial development, to its eventual release, and updated versions of the released version to help improve software or fix bugs still present in the software.- Pre-alpha...

 state, but it is effective enough for hobby programming.

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
Visual Basic
Visual Basic is the third-generation event-driven programming language and integrated development environment from Microsoft for its COM programming model...

, 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-user
End-user
Economics and commerce define an end user as the person who uses a product. The end user or consumer may differ from the person who purchases the product...

s. As with programs written in any interpreted language, wxBasic programs may also be run straight from the source code if wxBasic is present on the system, regardless of which system they were written on. This saves download time, as generated executables tend to be several orders of magnitude
Order of magnitude
An order of magnitude is the class of scale or magnitude of any amount, where each class contains values of a fixed ratio to the class preceding it. In its most common usage, the amount being scaled is 10 and the scale is the exponent being applied to this amount...

 greater than the source code from which they were compiled.

wxBasic is written primarily in C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

, with some C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

 linking it to the wxWidgets
WxWidgets
wxWidgets is a widget toolkit for creating graphical user interfaces for cross-platform applications. wxWidgets enables a program's GUI code to compile and run on several computer platforms with minimal or no code changes...

 library. wxWidgets supplies the cross-platform features, making wxBasic a very powerful, although beginner-friendly, programming language.

wxBasic runs on Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 using native controls, and Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 using the GTK+
GTK+
GTK+ is a cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the X Window System, along with Qt.The name GTK+ originates from GTK;...

 Library. A Macintosh port is being actively investigated.

wxBasic is a bytecode
Bytecode
Bytecode, also known as p-code , is a term which has been used to denote various forms of instruction sets designed for efficient execution by a software interpreter as well as being suitable for further compilation into machine code...

 based language, like Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

 or Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

.

It is licensed under the LGPL, so proprietary code can be linked against it.

Comprehensive example

To give an idea how the syntax looks like see the following program which implements a text viewer:


' from http://wxbasic.sourceforge.net/phpBB2/viewtopic.php?t=554
' Simple Text Viewer written in wxBasic
dim AppName = "Text Viewer"
fileName = ""

' Main window
dim frame = new wxFrame( Nothing, -1, AppName & " - Untitled Document" )
' Text edit control
dim control = new wxTextCtrl( frame, -1, "", wxPoint( 0, 0 ),
wxSize( 100, 100 ), wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH)

' Status bar - The one at the bottom of the window
dim status = frame.CreateStatusBar( 1 )
frame.SetStatusText("Ready")
'
' Dialog used for Open
dim fileDialog = new wxFileDialog( frame )
'
' add menubar to the frame
dim mBar = new wxMenuBar
frame.SetMenuBar(mBar)
'
' build the "File" dropdown menu
dim mFile = new wxMenu
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" )

Sub onFileOpen( event )
fileDialog.SetMessage("Open File")
fileDialog.SetStyle( wxOPEN )
If fileDialog.ShowModal = wxID_OK Then
fileName = fileDialog.GetPath
Ext = fileDialog.GetFilename
control.Clear
control.LoadFile( fileName )
frame.SetTitle( AppName & " - " & fileName )
frame.SetStatusText(Ext)
End If
End Sub
'
Connect( frame, wxID_OPEN, wxEVT_COMMAND_MENU_SELECTED, "onFileOpen" )

Sub onFileExit( event )
frame.Close(True)
End Sub
'
Connect( frame, wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, "onFileExit" )

' build the "Help" dropdown menu
dim mHelp = new wxMenu
mBar.Append(mHelp, "&Help")
mHelp.Append( wxID_HELP, "&About\tF1", "About this program" )
'
Sub onHelpAbout( event )
Dim msg = "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 )
End Sub
Connect( frame, wxID_HELP, wxEVT_COMMAND_MENU_SELECTED, "onHelpAbout" )

frame.Show(True)

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK