Yabasic

From Wikipedia, the free encyclopedia

Yabasic

Yabasic running an implementation of SameGame.
Developer: Marc-Oliver Ihm
Latest release: 2.763 / September 19, 2005
OS: Windows, Unix
Use: Programming
License: GNU General Public License, Artistic License
Website: http://www.yabasic.de/

Yabasic (Yet Another BASIC) is a free and open source BASIC interpreter for Windows and Unix platforms.[1] Yabasic is currently developed by Marc-Oliver Ihm. Yabasic is relatively small in file size at around 250 kilobytes.

Contents

[edit] History

Yabasic started as a very simple, basic interpreter around May 1995. Although it was released as version 1.0 it lacked many features like arrays and loops. A year later Yabasic was ported to the Win32 platform, creating version 2.0. Another big improvement was the addition of subroutines and libraries in version 2.57, allowing anyone to add their own functions to the language. [2]

[edit] Features

Yabasic can draw simple line graphics in colour as of version 2.760. As well as "conventional" features, Yabasic offers structured programming (various block structures, named subroutines with return values and code modules with separate namespaces). On the other hand, composite data structures are missing. Yabasic also offers the possibility to create a graphical user interface based on the GTK library. Passing of arguments is always by value, except for arrays, which are always by reference.

The interpreter is very lenient in syntactical matters - for example, both color and colour are legal variants for the same command. Likewise, there are a number of different versions for if and for constructs, giving the programmer freedom of choice in his design.

Another useful feature is the bind-command, allowing creation of executables by linking the interpreter to the source code.

Execution speed of the interpreter is reasonably high.

A version of Yabasic is available for Sony's PlayStation 2. It comes free with the console in Europe and Australasia. The demo disc containing the Yabasic interpreter is a PAL disc and is not intended for the United States or Japanese PlayStation 2 markets. It is recommended to have an additional USB-compatible keyboard for the PlayStation version of Yabasic because programming with a gamepad is rather impractical. Yabasic programs created on a PlayStation can be stored on memory cards for later retrieval or swapping with friends.

[edit] Examples

The classic Hello World program looks like this in Yabasic,

print "Hello World"

The follwing example will calculate prime numbers,

print "This program will calculate the prime numbers below the limit"
input "limit: " limit
n=2
do
  for i=2 to sqrt(n)
    if (frac(n/i)=0) then
      notprime=1
      break
    endif
  next i
  if notprime<>1 then
    print n
  endif
  notprime=0
  n=n+1
  if n>limit break
loop

[edit] Compiling at runtime

The interpreter also features the possibility to take string variables and "compile" them at runtime. For example,

x$= "sub printme()\n print \"Hello world!\" \nend sub"
compile(x$)

would create a new procedure,

sub printme()
 print "Hello world!"
end sub

This procedure can be invoked the 'traditional' way,

printme()

or via the slightly more clever:

y$= "printme()"
execute(y$)

[edit] Modifications

Because Yabasic is open source and dual-licensed under both the GPL and Artistic License, anyone can make their own versions and modifications of Yabasic. There is a version of Yabasic called "Flyab", which is a port of Yabasic to the Fltk toolkit. While "Flyab" only runs on BeOS at present, ports for Windows, Mac OS X and Linux are planned. Flyab adds the ability to Yabasic to create native graphical user interfaces on all supported platforms.[3]

[edit] References

  1. ^ "Yabasic". Official website of Yabasic. Saturday 20 January, 01:23 UTC http://www.yabasic.de.
  2. ^ "Yabasic". Official website of Yabasic. Thursday 25 January http://www.yabasic.de.
  3. ^ "team maui". Official website of flyab, 30 January http://team-maui.org/.

[edit] External links