Coder Social home page Coder Social logo

qbjs's Introduction

About QBJS

QBJS is an implementation of the Basic programming language for the web, with multimedia support and easy sharing of programs. It aims to be compatible with QB64, which in turn implements the same dialect as the classic QBasic.

The project is in active development as of 30 March 2022. It can be tried online on itch.io; documentation and releases are hosted on GitHub.

Support for browser APIs is built-in as of version 0.3.0-beta; a game engine is included separately.

qbjs's People

Contributors

boxgaming avatar grymmjack avatar fellippeheitor avatar felixp7 avatar

Stargazers

Facundo Ferrero avatar Jocelyn Stericker avatar Rick avatar  avatar Marcos LM avatar  avatar Alexander Fritsch avatar Cory Smith avatar veganaiZe avatar RetroNick's Youtube Channel avatar  avatar James Blackburn avatar  avatar  avatar Joohun, Maeng avatar Amal Ramakrishnan avatar MrKermit avatar  avatar  avatar Ethan Davidson avatar Masiosare Gutiérrez avatar  avatar  avatar  avatar Stefan Oestreicher avatar João Norberto de Souza Junior avatar Graham McNeill avatar  avatar Zhao Xin avatar Marcos Cruz avatar  avatar PQCraft avatar Samuel Gomes avatar Boran Car avatar Gkoran Stoilkovits avatar Alan Zhiliang Feng avatar Erdem Ersoy avatar Biterr avatar  avatar  avatar  avatar  avatar  avatar Antonio Muñoz avatar

Watchers

 avatar Derrick Simpson avatar  avatar  avatar Biterr avatar  avatar

qbjs's Issues

Different INPUT behavior comparing to QBasic or QB64

The results of running the following piece of code on QBasic and QBJS are different.

INPUT "Enter a number: ", x
 
x = x + 5
PRINT "X is now: "; x

Regards to QBasic,

  • it considers x as a number instead of a string;
    • note: if you use a variable name x$, then it will accept a string.
  • if you input "abc" and press ENTER, it will prompt you with Redo from start and ask you to input again;
    • note: empty strings are allowed.

Regards to QBJS,

  • it considers variable x as a string;
  • when user input "abc", the PRINT result will be abc5.

This issue may be related to #33.

Always show Export button on Share dialog

"In the Share / Export dialog, the Export button should be visible from the start, just greyed out while the launch mode is set to IDE (default)."

  • No Time To Play (itch.io)

GOTO not supported?

First of all thanks for doing this really nice QBasic implementation!
I realized that the GOTO statement does not seem to be supported, at least when testing it under https://qb64.com/qbjs.html - is this by design or a yet unimplemented command?
I know it's not best practice to use GOTO, but it breaks compatibility with programs who nevertheless use it.

`SUB`s and `FUNCTION`s with `.` in names fail in QBJS

SUBs and FUNCTIONs with . in names fail in QBJS

Example code which works in QB64:

CALL TEST.one("test")

SUB TEST.one(s$)
	PRINT s$
END SUB

Causes failure in QBJS:

ERROR  :0 : missing ( before formal parameters runProgram@https://qbjs.org/qbjs-ide.js?v=0.7.3.2:252:22

https://qbjs.org/?code=Q0FMTCBURVNULm9uZSgidGVzdCIpCgpTVULKFnMkKQogICAgUFJJTlQgcyQKRU5EIFNVQg==

The . is why. In QB64 compiler it changes the . to something else:

void SUB_TEST__ASCII_CHR_046__ONE(qbs*_SUB_TEST__ASCII_CHR_046__ONE_STRING_S){

example..

Firefox-specific text placement issues

"A couple of small bugs when running code in Firefox 102:

  1. locate only sets the correct row, not the column;
  2. when typing at an input prompt, the entered text is offset from the baseline.

Neither happens in Opera 78."

  • No Time To Play (itch.io)

Implement QB64 Clipboard functions

This implementation should be possible using the navigator.clipboard and applies to the following keywords:

  • _CLIPBOARD$ (function)
  • _CLIPBOARD$ (statement)
  • _CLIPBOARDIMAGE (function)
  • _CLIPBOARDIMAGE (statement)

Printing numbers should keep a space to the left

It's the reserved space for a negative sign, and also helps when printing sequentially to the screen, since it'll automatically space numbers from each other.

FOR i = 1 TO 5
    PRINT i;
NEXT

That results in " 1 2 3 4 5" in QB64, but yields "12345" in qbjs.

Implement Remaining MKn$, CVn Functions

MKI$, MKL$, MKS$, and MKD$ convert numbers to numeric strings that can be stored in FIELD statement string variables. CVI, CVL, CVS, and CVD convert those strings back to numbers.

MKI$(integer-expression%)
MKL$(long-integer-expression&)
MKS$(single-precision-expression!)
MKD$(double-precision-expression#)
CVI(2-byte-numeric-string)
CVL(4-byte-numeric-string)
CVS(4-byte-numeric-string)
CVD(8-byte-numeric-string)

Function Returns Function Returns
MKI$ A 2-byte string CVI An integer
MKL$ A 4-byte string CVL A long integer
MKS$ A 4-byte string CVS A single-precision number
MKD$ An 8-byte string CVD A double-precision number

Implement MKSMBF$, MKDMBF$, CVSMBF, CVDMBF Functions

MKSMBF$ and MKDMBF$ convert IEEE-format numbers to Microsoft-Binary-format numeric strings that can be stored in FIELD statement string variables. CVSMBF and CVDMBF convert those strings back to IEEE-format numbers.

MKSMBF$(single-precision-expression!)
MKDMBF$(double-precision-expression#)
CVSMBF (4-byte-numeric-string)
CVDMBF (8-byte-numeric-string)

Function Returns
MKSMBF$ A 4-byte string containing a Microsoft-Binary-format number
MKDMBF$ An 8-byte string containing a Microsoft-Binary-format number
CVSMBF A single-precision number in IEEE format
CVDMBF A double-precision number in IEEE format

These functions are useful for maintaining data files created with older versions of Basic.

Example:

TYPE Buffer
  SngNum AS STRING * 4
  DblNum AS STRING * 8
END TYPE
DIM RecBuffer AS Buffer
OPEN "TESTDAT.DAT" FOR RANDOM AS #1 LEN = 12
SNum = 98.9
DNum = 645.3235622#
RecBuffer.SngNum = MKSMBF$(SNum)
RecBuffer.DblNum = MKDMBF$(DNum)
PUT #1, 1, RecBuffer
GET #1, 1, RecBuffer
CLOSE #1
PRINT CVSMBF(RecBuffer.SngNum), CVDMBF(RecBuffer.DblNum)

The variable naming convention does not follow how it does on QBasic.

This piece of code runs fine on QBasic:

a = 42
b$ = "Hello"
PRINT a
PRINT b$

But result in the following error when run on QBJS:

ERROR : 4 : b$ is not defined
ReferenceError: b$ is not defined
    at eval (eval at runProgram (https://qbjs.org/:100:30), :10:25)
    at async runProgram (https://qbjs.org/:356:17)

It seems that QBJS doesn't follow QBasic's variable naming convention, for example, b$ means a string variable, and you can not run code such as b$ = 42.

`CIRCLE` keyword using negative radians not like QB and QB64

CIRCLE keyword using negative radians is not 100% compatible with QBasic or QB64.

I mentioned to @boxgaming and he said he also tried it and it is a bug. From discord:

Interesting, I tested this in QBasic too and it works exactly like qb64. Negative radian start and end values are interpreted the same as positive radian values as far as the arc is concerned. Then I saw this in the documentation for circle:

Negative radian values can be used to draw lines from the end of an arc or partial ellipse to the circle center.

Screenshots

Result of using provided code in QB64:
image

Note that by using negative radians we can achieve "slices"

Result of using provided code in QBJS:
image

Note that in QBJS there are no slices, it does not render the same way.

QBJS Code to test:
https://qbjs.org/?code=U0NSRUVOIDEzCkNMUyAwLCAwClBSSU5UICIxLzQiCidUTApDSVJDTEUgU1RFUCAoMCwwKSwgNTAsIDEyLCBfRDJSKDnEEsUKMTjECzAuNwpTTEVFUAonVFLZPjTHNMk9xUfLPELaPDPHMzI3yT4zNtA/+gC5MO0Ar8tKyj/0AQ4gU0xJQ0VT5QEVxgzZYjIsIC3qANXGC/MBHd9GNMg75gDdy1LLRkLfRuQBLcY65gDkzFLMR/8A0+QBNewAyMxT/QE3MiBWRVJUSUNBTOQBOU9QIEhBTEbcZusAoPYBOEJPVFRPTd5I6AJe6wHj8ADz9QCsSE9SSVpPTlTlAK5MRUZU3mcx8QMD8AESJ1JJR0jfRvMCz+8B5v0BWOsCmOcBX/8By+kBy+wCWPwBZ99Q6QKo7AIb/wFv8AFv6gDF6QF233Yx8wNk+wF+3071AybuAYY=

QB64 Code to test:

SCREEN 13
CLS 0, 0
PRINT "1/4"
'TL
CIRCLE STEP (0,0), 50, 12, _D2R(90), _D2R(180), 0.7
SLEEP
'TR
CIRCLE STEP (0,0), 50, 14, _D2R(0), _D2R(90), 0.7
SLEEP
'BR
CIRCLE STEP (0,0), 50, 13, _D2R(270), _D2R(360), 0.7
SLEEP
'BL
CIRCLE STEP (0,0), 50, 10, _D2R(180), _D2R(270), 0.7
SLEEP

CLS 0, 0
PRINT "1/4 SLICES"
'TL SLICE
CIRCLE STEP (0,0), 50, 12, -_D2R(90), -_D2R(180), 0.7
SLEEP
'TR SLICE
CIRCLE STEP (0,0), 50, 14, -_D2R(360), -_D2R(90), 0.7
SLEEP
'BR SLICE
CIRCLE STEP (0,0), 50, 13, -_D2R(270), -_D2R(360), 0.7
SLEEP
'BL SLICE
CIRCLE STEP (0,0), 50, 10, -_D2R(180), -_D2R(270), 0.7
SLEEP

CLS 0, 0
PRINT "1/2 VERTICAL"
'TOP HALF
CIRCLE STEP (0,0), 50, 10, _D2R(360), _D2R(180), 0.7
SLEEP
'BOTTOM HALF
CIRCLE STEP (0,0), 50, 14, _D2R(180), _D2R(360), 0.7
SLEEP

CLS 0, 0
PRINT "1/2 HORIZONTAL"
'LEFT HALF
CIRCLE STEP (0,0), 50, 11, _D2R(90), _D2R(270), 0.7
SLEEP
'RIGHT HALF
CIRCLE STEP (0,0), 50, 13, _D2R(270), _D2R(90), 0.7
SLEEP

CLS 0, 0
PRINT "1/2 VERTICAL SLICES"
'TOP HALF SLICE
CIRCLE STEP (0,0), 50, 10, -_D2R(360), -_D2R(180), 0.7
SLEEP
'BOTTOM HALF SLICE
CIRCLE STEP (0,0), 50, 14, -_D2R(180), -_D2R(360), 0.7
SLEEP

CLS 0, 0
PRINT "1/2 HORIZONTAL SLICES"
'LEFT HALF SLICE
CIRCLE STEP (0,0), 50, 11, -_D2R(90), -_D2R(270), 0.7
SLEEP
'RIGHT HALF SLICE
CIRCLE STEP (0,0), 50, 13, -_D2R(270), -_D2R(90), 0.7
SLEEP

Add Upload button to Files Tab

"The Files tab in the console should have a button to upload files in addition to drag&drop, because a button is more accessible and more discoverable. Failing that, a visual indication that you can drag&drop files would help somewhat."

  • No Time To Play (itch.io)

qbjs is crashing when I press run

My browser start to slowly freeze and then crash when I press run
log:
Feature Policy: Skipping unsupported feature name “autoplay”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “midi”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “monetization”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “xr-spatial-tracking”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “gyroscope”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “accelerometer”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “xr”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “cross-origin-isolated”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “autoplay”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “midi”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “monetization”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “xr-spatial-tracking”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “gyroscope”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “accelerometer”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “xr”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “cross-origin-isolated”. lib.js:2:39203 Feature Policy: Skipping unsupported feature name “autoplay”. lib.js:2:50992 Feature Policy: Skipping unsupported feature name “midi”. lib.js:2:50992 Feature Policy: Skipping unsupported feature name “monetization”. lib.js:2:50992 Feature Policy: Skipping unsupported feature name “xr-spatial-tracking”. lib.js:2:50992 Feature Policy: Skipping unsupported feature name “gyroscope”. lib.js:2:50992 Feature Policy: Skipping unsupported feature name “accelerometer”. lib.js:2:50992 Feature Policy: Skipping unsupported feature name “xr”. lib.js:2:50992 Feature Policy: Skipping unsupported feature name “cross-origin-isolated”. lib.js:2:50992 Unable to check top-level optout: Permission denied to access property "document" on cross-origin object content.js:1:1564 unreachable code after return statement

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.