GithubHelp home page GithubHelp logo

basicpp's Introduction

C++ today is as simple as BASIC was in the 80s

Single header BASIC emulation in C++. This is based on my (flawed) memory of the BASIC dialect in the EACA Colour Genie computer I got on my 15th birthday.

Versions

Basic

Original BASIC - AKA Dartmouth BASIC

Header file: basic.hpp

Example program:

#include "basic.hpp"

int main()
{
  _10: LET COUNT = 1;
  _20: LET SUM = 0;
  _30: LET STACK$ = ".";
  _40: LET TRY = 0;
  _50: FOR TRY = 3 TO 1 STEP -1;
  _60: PRINT "You have ", TRY, " chances to get this right: ";
  _70: INPUT "Enter a positive number ", COUNT;
  _80: IF COUNT > 0 THEN GOTO _130;
  _90: PRINT "I said positive. ", COUNT, " isn't";
 _100: NEXT;
 _110: PRINT "I give up on you!";
 _120: END;
 _130: GOSUB _160;
 _140: PRINT "SUM=", SUM, " STACK=", STACK$;
 _150: END;
 _160: SUM = SUM + COUNT;
 _170: COUNT = COUNT - 1;
 _180: IF COUNT > 0 THEN GOSUB _160;
 _190: STACK$ = STACK$ + STACK$;
 _200: RETURN;
}

SBASIC

Structured BASIC - AKA SBASIC

Header file: structured_basic.hpp

Example program:

#include "structured_basic.hpp"

int main()
{
  _10: LET X = 1;
  _20: INPUT "enter a positive number: " , X;
  _30: IF X > 0 THEN GOTO _60;
  _40: PRINT "Positive means greater than 0";
  _50: GOTO _20;
  _60: LET i = 0;
  _70: DO ;
  _80: PRINT i+1, " Basic is awesome";
  _90: i = i + 1 ;
 _100: LOOP WHILE ( i < X );
}

Limitations

  • C++11 or later (easy to back-port, but why?)
  • Those pesky semicolons...
  • Variables must be defined prior to use
  • Can't be used in kernel modules ;-)
  • Many language features missing, e.g. PRINT USING and Most I/O

PR's for fixes and added functionality are most welcome.

basicpp's People

Contributors

rollbear avatar mcsh avatar jbush001 avatar

Watchers

 avatar

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.