QBJS - Fun Facts! - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: QBJS, BAM, and Other BASICs (https://staging.qb64phoenix.com/forumdisplay.php?fid=50) +--- Thread: QBJS - Fun Facts! (/showthread.php?tid=1610) Pages:
1
2
|
QBJS - Fun Facts! - dbox - 04-10-2023 Starting a thread here to post fun facts about QBJS that you might not know. Fun Fact #1 - You can define optional parameters! Code: (Select All) PrintLines "First Test" Output: Code: (Select All) First Test Try it out on QBJS RE: QBJS - Fun Facts! - mnrvovrfc - 04-10-2023 RE: QBJS - Fun Facts! - Sprezzo - 04-10-2023 Say, this is a pretty enlightening demo dbox! In case people missed it, the demo implies undefined is a reserved word in qbjs. Power overwhelming! RE: QBJS - Fun Facts! - mnrvovrfc - 04-11-2023 STRING$() function has weird behavior in QBJS. Is this on purpose? Because I tried to test with the following code: Code: (Select All) print string$(80, 42) For the first line, I got "42" replicated 40 times. In QuickBASIC and "clones" it gives me 80 asterisks. Even weirder, I do: Code: (Select All) print string$(10, 432) and the result is "4324324324". Not sure but it's supposed to flag an error that the second parameter must be type byte. Otherwise this is pretty neat and I could finally shelf my REPEAT$(). LOL. RE: QBJS - Fun Facts! - dbox - 04-11-2023 (04-11-2023, 06:11 AM)mnrvovrfc Wrote: STRING$() function has weird behavior in QBJS. Is this on purpose? Good catch! Looks like I missed the fact that the STRING$ function can take either a string or a character code. Fix will be included in the next release. RE: QBJS - Fun Facts! - dbox - 04-11-2023 Fun Fact #2 - Custom types can be returned from functions! Code: (Select All) Screen 12 Try it on QBJS RE: QBJS - Fun Facts! - vince - 04-11-2023 you can write things without brackets ie Code: (Select All) cmul q, q, g RE: QBJS - Fun Facts! - dbox - 04-13-2023 Fun Fact #3 - QBJS has native support for associative arrays (dictionary). This feature is sometimes also known as a map or hashmap. Code: (Select All) Dim colors() As _Unsigned Long Try it on QBJS RE: QBJS - Fun Facts! - bplus - 04-13-2023 Ah so that's how dictionary's are supposed to be used. I was wondering how I might apply the dictionary code I was working on yesterday. So I need to rename the Function that does a Value Lookup from a Key to something short and easy and maybe do a value conversion for numbers. Thanks for new ideas! Now I wonder, could I do a whole program with variables and values from a dictionary? Bet I can! Be fun to try anyway Ha! The JS part is really showing up the QB part ;-)) RE: QBJS - Fun Facts! - mnrvovrfc - 04-14-2023 (04-13-2023, 11:48 AM)dbox Wrote: This could be faked as function, and on 64-bit it's faster than any "dictionary" implementation: Code: (Select All) FUNCTION colors~& (mycolor$) |