Skip to content
Henrik Lievonen edited this page May 1, 2014 · 11 revisions

Eppabasic is a new, simple web based basic language inspired by Coolbasic. The idea of the language is to be as simple to start programming with as possible.

Code editor

The official web site of the language (under construction) contains a web based IDE (also available as downloadable zip) with syntax highlighting, spell checking and documentation with sample programs for every command.

Running programs

The IDE contains compiler which compile the Eppabasic code into native Javascript which is then runned in a separate window. The programs can be shared with other users via the web site of the language, but programs can also be downloaded as single .html files for offline usage.

Graphics

The program uses html5 canvas elements for drawing, possibly with WebGl. It is yet to be desided how this is exactly to be implemented.

Drawing commands

  • LINE x1, y1, x2, y2
  • RECT x, y, w, h
  • ELLIPSE x, y, w, h (x and y being the center of the ellipse)
  • TRIANGLE x1, y1, x2, y2, x3, y3

Audio

Eppabasic supports loading audio from files and playing it back via Javascript Audio object, with html audio element as a backup implementation.

Desing goals

  • Simple to start programming with
  • Easy to make graphics
  • Works everywhere
  • Copied code works without any other tweeking (no compiler settings)

Syntax

This is a simple code to show off a syntax proposal. It is yet to be decided whether keywords and function names should be with capitals (eg. IF, ADDTEXT) or with CamelCase(eg. If, AddText).

DIM a AS INTEGER = 10
DIM b AS INTEGER = 20
DIM c AS INTEGER = (a + b) * a

ADDTEXT 10, 10, STR(c)
IF a > b AND b < c THEN
    FOR i = b TO a STEP -2
        LINE 10, 30, TEXTWIDTH(STR(c)), 30 + i*20
    NEXT i
ELSE IF b > c THEN
    SELECT a
        CASE 0 TO 10
            ' Values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
        CASE 11, 13
            ' Values 11, 13
        CASE ELSE
             ' All other values, eg. negative values, 12, and values over 13
    END SELECT
ELSE
    ' Do something
END IF

DO
    CLEAR
    ' Stuck here
    DRAWSCREEN
FOREVER

FUNCTION ADD(a AS INTEGER, b AS INTEGER) AS INTEGER
    RETURN a + b
END FUNCTION

SUB PRINT(s AS STRING)
   STATIC y AS INTEGER = 0
   ADDTEXT 0, y, s
   y = y + 10
END SUB

Extensibility

The language can be extended by extension libraries (possibly only for developers of Eppabasic). Extensions consist of Javascirpt file containing the program code of the extension and a map file mapping Eppabasic code to Javascript. For example: Javascript:

function somefuncInJs(x1, y1, x2, y2) {
    // Do something
}

Map:

FUNCTION SOME(x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER) AS INTEGER
    RETURN NATIVE(somefuncInJs(x1, y1, x2, y2))
END FUNCTION

Or:

FUNCTION SOME(x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER) AS INTEGER: somefuncInJs
Clone this wiki locally