Yabasic

From Wikipedia, the free encyclopedia

Yabasic

Yabasic running an implementation of SameGame.
Developed by Marc-Oliver Ihm
Latest release 2.763 - Final / August, 2007
OS Windows, Unix
Genre 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 was developed by Marc-Oliver Ihm. The Yabasic interpreter 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]

Since then, Ihm has stated that "probably (he) will not develop Yabasic any further (beyond version 2.763) within the foreseeable future", due to a lack of time on his hands. Yet, there are efforts from other developers to pick up the project which have already resulted in minor bugfixes.[3] The aim is to completely rewrite the interpreter before expanding functionality.

[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 their design.

Yabasic programs can be self-modifying (see section below) by turning string variables into blocks of code through the compile command.

Another useful feature is the bind instruction, allowing the creation of standalone executables by linking the interpreter to the source code into a single file.

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 following 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] Adding code during execution

String variables can be "compiled" into program code at runtime.

For example, the sequence

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

would create a new procedure,

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

This procedure can then be invoked from this point on in either 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.[4]

Sony also packaged a version of Yabasic for the PlayStation 2 with all PS2 consoles in PAL territories. It is widely rumored[who?] that this was in order to try and class the games console as a home computer in order to save money on import tax.

[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. ^ Yabasic::Dev Article Future of Yabasic - Basicprogramming.org
  4. ^ "team maui". Official website of flyab, 30 January http://team-maui.org/.

[edit] External links