QBJS - Fun 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: QBJS - Fun Facts! (/showthread.php?tid=1610) Pages:
1
2
|
RE: QBJS - Fun Facts! - CharlieJV - 04-14-2023 (04-14-2023, 03:04 AM)mnrvovrfc Wrote:(04-13-2023, 11:48 AM)dbox Wrote: Sure, but the "dictionary" code is way easier to read, and much better for filling the dictionary with values coming from DATA statements or from files. The data source, as-is, works as documentation. If speed is critical, then pick the speedy one. If flexibility and readability are critical, then go for the dictionary. RE: QBJS - Fun Facts! - SMcNeill - 04-14-2023 I'd think, for speed and readability, I'd just use a function with select case. Code: (Select All) FUNCTION colors~& (mycolor$) Just as fast as the IF...ELSEIF... version. Uses almost the same amount of coding as the qbjs version does to define the dictionary, and is just as easily readable. RE: QBJS - Fun Facts! - vince - 04-14-2023 Some more fun facts if you wish to run QBJS completely offline and for it to appear like a native program you can do so by: - downloading the QBJS project from github to your local hard drive - if you are using chrome/chromium you can use the --app="~/qbjs-master/index.html" command-line option which will start the browser with none of the 'browsing' features or decorations so it appears just like a native app - and while javascript browser programs may not reach the performance of native compiled C++ in some circumstances, the browser QBJS IDE is, in fact, much faster and better performing than QB64's (mainly due to the incredibly poor implementation of the multiline textbox in QB64's default IDE) Same can be said for smartphones/tablets, ie Android and iPhone devices: either place the QBJS master folder in your internal storage and simply upload .BAS files or use QBJS's export feature and upload the prepackaged html/javascript and run it with your device's browser with touchscreen and full screen support for a seamless app experience while also conveniently bypassing any of app store or developer mode layers If you are indeed concerned about javascript's performance or the capability of your smartphone apps to directly access the devices hardware (ie bluetooth, camera, etc) then you are very far lost to be considering a QBasic based language/compiler RE: QBJS - Fun Facts! - dbox - 04-14-2023 (04-14-2023, 11:38 AM)SMcNeill Wrote: I'd think, for speed and readability, I'd just use a function with select case. I think perhaps my first example was too simplistic. It was just intended to show the syntax for how the associative array (or dictionary) could be used in QBJS. If the use case really only had three colors, I would just define variables for each. Here's a more fleshed out example. Say you want to read in a flat file containing client information, and you want to be able to lookup a client by their account number. An associative array could make that exercise pretty easy: Code: (Select All) Type Account Try it on QBJS RE: QBJS - Fun Facts! - mnrvovrfc - 04-14-2023 Put it into string arrays and search by field? Maybe not sequentially? Besides the output shown is wrong. For the requested policy number the user should be "Victoria Armstrong". Unless those are scrambled in a certain way not shown obviously by the program. Even running this thing live displays the same thing. Also putting down "Lyle's" account number gives me "Eve" instead. Before you guys keep pelting me, I recognize associative arrays are useful because I also program in Lua. RE: QBJS - Fun Facts! - dbox - 04-14-2023 (04-14-2023, 02:53 PM)mnrvovrfc Wrote: Put it into string arrays and search by field? Maybe not sequentially? Another good catch @mnrvovrfc! Apparently, I put that together too fast. It matters where you Dim your variables. I've updated the original post with the corrected version. RE: QBJS - Fun Facts! - dbox - 04-21-2023 Fun Fact #4 - You can call native Javascript from your QBJS program! Here's a simple example that utilizes the browser's text-to-speech functionality: Code: (Select All) Dim s As String Try it on QBJS! RE: QBJS - Fun Facts! - dbox - 01-31-2024 Fun Fact #5 - _LoadImage can load images directly from a URL! |