Chuck Norris Facts! - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: QBJS, BAM, and Other BASICs (https://qb64phoenix.com/forum/forumdisplay.php?fid=50) +--- Thread: Chuck Norris Facts! (/showthread.php?tid=1635) Pages:
1
2
|
RE: Chuck Norris Facts! - grymmjack - 04-27-2023 LOL! awesome. Full screen and everything even with robot voices! RE: Chuck Norris Facts! - grymmjack - 04-27-2023 (04-21-2023, 08:11 PM)dbox Wrote: Have you ever wished you had a desktop background that would tell you random Chuck Norris facts? Haven't we all? 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? 2. Fetch! That's awesome, does this have a QB64 counterpart? 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. Thanks for sharing this great and simple example. RE: Chuck Norris Facts! - mnrvovrfc - 04-27-2023 (04-27-2023, 03:17 AM)grymmjack Wrote: 2. Fetch! That's awesome, does this have a QB64 counterpart? https://qb64phoenix.com/qb64wiki/index.php/Downloading_Files The first example might be enough to get a text file. RE: Chuck Norris Facts! - dbox - 04-27-2023 (04-27-2023, 03:17 AM)grymmjack Wrote: This is really great. Questions: 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! RE: Chuck Norris Facts! - mnrvovrfc - 04-27-2023 If the text file to retrieve is a JSON and it's a certain format, then something rather simple to extract the "facts" could be employed: https://qb64phoenix.com/forum/showthread.php?tid=1249&pid=11254#pid11254 Otherwise for a JSON there is this to consider: https://qb64phoenix.com/forum/showthread.php?tid=1556&pid=14448#pid14448 RE: Chuck Norris Facts! - grymmjack - 04-28-2023 (04-27-2023, 11:45 AM)dbox Wrote:Quote:2. Fetch! That's awesome, does this have a QB64 counterpart? Thanks @mnrvovrfc I'll check that link. OK got it. Also LOL on Chuck Norris being aware of the undocumented features. Thanks @dbox for the explanation. |