![]() |
|
QBJS v0.9.0 - Release - 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: QBJS v0.9.0 - Release (/showthread.php?tid=3376) |
RE: QBJS v0.9.0 - Release - mdijkens - 04-22-2025 I'm taking a first look at QB.js to investigate mobile app development. I can't find documentation or examples for calling/using javascript functions I've only found a small example using inline javascript with an alert. I'd like to try for example accessing the GPS, (bluetooth) serial comms, REST calls, etc. Do these samples/doc exists? RE: QBJS v0.9.0 - Release - dbox - 04-23-2025 (04-22-2025, 10:23 AM)mdijkens Wrote: I'm taking a first look at QB.js to investigate mobile app development. Hi @mdijkens, I'm sure there could be more documentation along these lines. So, I'll write some right here... I've tried to keep it as simple as possible for calling out to native Javascript from QBJS. The main mechanism for this is the $If Javascript metacommand. Everything between the starting "$If Javascript Then" and "$End If" lines will essentially be included as-is by the compiler and executed as plain Javascript with no transformation. From within this block you can reference any non-array variables directly that were declared in the Basic code: Here's another example utilizing the browser's geolocation API. I usually like to try to wrap calls to native Javascript inside a function or sub that is easy to call from within the rest of the application: View in QBJS Code: (Select All)
This is a great way to make reusable code that can be shared with a wider BASIC programming audience. This is basically the approach that is used for the standard QBJS Import libraries. You can peruse the source code for these libraries and see more examples here: https://github.com/boxgaming/qbjs/tree/main/lib. Let me know if you have additional questions. If you come up with something cool make sure you share it here, maybe we can add it to the standard QBJS libraries. |