Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Chuck Norris Facts!
#14
(04-27-2023, 03:17 AM)grymmjack Wrote: This is really great. Questions:

1. Everything is JS in QBJS - except how you write it using QB syntax or not, still transpiles to JS, right?

Yes, in much the same way that C/C++ is the target of the QB64 compiler, Javascript is the target of the QBJS compiler.  For the browser the generated JS is effectively the executable.  When you click Run in the QBJS IDE it first compiles the QBJS source to Javascript and then runs the generated code.

Quote:2. Fetch! That's awesome, does this have a QB64 counterpart?

@mnrvovrfc pointed you in the right direction on this one.  There is not a single method analog in QB64, but you can use the HTTP methods to do the same thing.

Quote:3. JSON.parse - native JS inside the QBJS part - it's a little confusing to me - this is javascript inside of QBJS but without $If Javascript like lower down - can you explain how you do that, or how we would know what we can do? If it's in the docs, I'm sorry.

I'm afraid for this example I used a couple of undocumented features: the Fetch method and the JSON library, so I understand why it is confusing.  The reason I haven't documented these yet is because I am still evaluating their current implementation and they are likely still subject to change.  (Chuck Norris is aware of all undocumented features.)

The Fetch method in particular, while very convenient for downloading text or JSON, does not really have provision for downloading binary content.  Also, since adding this method early on in development I have refined the naming conventions that I'm using in QBJS to avoid future naming conflicts.  In general, I'm taking this approach:

* Undecorated keywords are generally reserved for QBasic methods.
* Methods prefixed with an underscore (_) are reserved for QB64 methods.
* New QBJS methods will be provided in libraries prefixed with the library name (e.g. Dom.Add, JSON.Parse, Storage.Get)

The exception to this rule is for the Import and Export keywords in QBJS that allow you to include this extended library functionality in your QBJS program.  There is more detail on the subject here for anyone interested.

The JSON functionality needs to be documented.  The reason it has not been to this point is because it currently is "built-in" and does not require an Import statement to include in your QBJS program which is also inconsistent with the rules I outlined above.

Thanks for the feedback and questions!
Reply


Messages In This Thread
Chuck Norris Facts! - by dbox - 04-21-2023, 08:11 PM
RE: Chuck Norris Facts! - by mnrvovrfc - 04-21-2023, 11:24 PM
RE: Chuck Norris Facts! - by SMcNeill - 04-22-2023, 10:55 AM
RE: Chuck Norris Facts! - by dbox - 04-22-2023, 11:04 AM
RE: Chuck Norris Facts! - by SMcNeill - 04-23-2023, 01:29 AM
RE: Chuck Norris Facts! - by CharlieJV - 04-23-2023, 05:59 PM
RE: Chuck Norris Facts! - by bplus - 04-22-2023, 12:41 PM
RE: Chuck Norris Facts! - by dbox - 04-22-2023, 01:04 PM
RE: Chuck Norris Facts! - by aurel - 04-23-2023, 10:34 AM
RE: Chuck Norris Facts! - by dbox - 04-23-2023, 11:25 PM
RE: Chuck Norris Facts! - by grymmjack - 04-27-2023, 03:13 AM
RE: Chuck Norris Facts! - by grymmjack - 04-27-2023, 03:17 AM
RE: Chuck Norris Facts! - by mnrvovrfc - 04-27-2023, 03:24 AM
RE: Chuck Norris Facts! - by dbox - 04-27-2023, 11:45 AM
RE: Chuck Norris Facts! - by grymmjack - 04-28-2023, 12:53 AM
RE: Chuck Norris Facts! - by mnrvovrfc - 04-27-2023, 04:35 PM



Users browsing this thread: 4 Guest(s)