Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with QBJS
#1
Hello,
Either I have found a bug or there's something I'm not doing right

This link for QBJS:
https://qbjs.org/

I'm using it while looking at the Phoenix WIKI page for CIRCLE here
https://qb64phoenix.com/qb64wiki/index.php/CIRCLE

In it I copy the example code into QBJS, this code
Code: (Select All)

SCREEN 12

r& = 200 'radius    change circle size and position here
cx& = 320 'center x horizontal
cy& = 240 'center y vertical

DO
  i = _MOUSEINPUT
  x& = _MOUSEX
  y& = _MOUSEY
  xy& = ((x& - cx&) ^ 2) + ((y& - cy&) ^ 2) 'Pythagorean theorem
  IF r& ^ 2 >= xy& THEN CIRCLE (cx&, cy&), r&, 10 ELSE CIRCLE (cx&, cy&), r&, 12
LOOP UNTIL INKEY$ = CHR$(27) 'escape key exit

Try to run it and I get the error
ERROR : 0 :
expected expression, got ')'
_runProgram@https://qbjs.org/qbjs-ide.js?v=0.8.2:265:26

After some experimenting I found that this code will run
Code: (Select All)

a = 0
b = 0
a = a + b
 

But this will not

Code: (Select All)

a& = 0
b& = 0
a& = a& + b&
 

expected expression, got ';'

Why is that? I can't use QBJS to learn keywords in QB64, it fails for things like this. I'm lost as to what I did wrong.
______________________________
I'm with you fellers
Reply
#2
FIXED:


Mainly have to Dim all variables, but replace i = _mouseinput with what I have works better in both QB and JS specially with _Limit 60.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#3
Ok, awesome! I had doubts about how to handle _Mouseinput, but had more confidence in vars that end in &
Thanks!
Jack
______________________________
I'm with you fellers
Reply
#4
so is there an implied option _explicit in qbjs?

the top line could also be:

Code: (Select All)
Dim As Long r, cx, cy, x, y, xy
then the programmer doesn't have to key in the ampersands after variable names which are type long.
Reply
#5
Yes! use Option _Explicit to setup QB64 code to port to QBJS absolutely good idea!

You can comment it out after setup everything in QB64. Maybe, probably, QBJS just ignores Option _Explicit if you don't comment it out, now. Honestly its been awhile since I've practiced porting to QBJS.
I know dbox is working on big update soon.

Also reading over some notes of other problems I had:
use integers only for array indexes
use integers for pset and other graphics x, y
don't step 0 anything in Lines, ie a QB64 Circle Fill Routine using lines to fill a circle
QBJS has a circle fill built in I have code somewhere for that fix if anyone wants it.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  UDT problems eoredson 31 6,313 11-13-2023, 05:20 AM
Last Post: eoredson

Forum Jump:


Users browsing this thread: 1 Guest(s)