Coder Social home page Coder Social logo

jscriptbasic's Introduction

ScriptBasic for Java

Build Status

ScriptBasic for Java is a BASIC interpreter that can be embedded into Java programs. With SB4J you can script your application (or let the users to script) in good old BASIC. You can start in the JVM an interpreter and execute for example

PRINT "hello, I am BASIC"
PRINT "\nthe numbers from 1 to 10 are\n"
FOR I=1 to 10
  PRINT I,"\n"
NEXT I

SB4J has all the BASIC language features, assignments, loops, subroutines, global and local variables and no GOTO statement. Seriously.

To embed the interpreter into your application you need to use SB4J as a dependency

  <dependency>
    <groupId>com.scriptbasic</groupId>
    <artifactId>jscriptbasic</artifactId>
    <version>1.0.5</version>
  </dependency>

and then use the JSR223 defined scripting interface or use the ScriptBasic native integration API.

The simplest way is to

     ScriptBasic.getEngine().eval("PRINT \"hello world\"");

get an execution engine and eval() the program source. There are other possibilities. You can specify the file where the source code is, a java.io.Reader to read the source code and there are even more advanced possibilities.

The BASIC language contains all the usual BASIC features, subroutines, local and global variables, conditional statements, loops and so on. (No GOTO!) Your host program can directly call subroutines, read and write global variables, provide methods implemented in Java to be called from BASIC code.

The interpreter can safely be integrated to applications as the BASIC programs can not access arbitrary objects and call Java methods at their will and there are other features that help controlling the scripts in the application. The language is a "no freak out" language, so you can put the programming possibility into the hands of users who would not ever touch Python, Groovy or some other programming language.

Documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.