Rotate and Scale Mesh Shape - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Programs (https://staging.qb64phoenix.com/forumdisplay.php?fid=7) +---- Thread: Rotate and Scale Mesh Shape (/showthread.php?tid=1179) Pages:
1
2
|
RE: Rotate and Scale Mesh Shape - TerryRitchie - 11-24-2022 (11-24-2022, 07:19 PM)james2464 Wrote: Nice program...the geometry becomes really interesting. I won't write code without having OPTION _EXPLICIT as my first line of code. As others have pointed out it forces you to declare every variable but I find it handy for another reason as well. Often times when I'm writing code I'll create lots of variables, or share variables, within my functions and subroutines. As the code progresses some of these variables end up not being used. A quick ' (REM) in front of a declared variable will show if I'm still using it. For example SUB ThisIsMySUB() SHARED ThisVariable AS LONG SHARED ThatVariable AS LONG DIM AnotherVariable AS INTEGER DIM YetAnotherVariable AS INTEGER etc.. When I get close to completing a project and start the process of cleaning the code I can just REM out each SHARED and DIM line individually. The IDE will complain if a variable is in use because OPTION _EXPLICIT is the first line of code. If the IDE complains I know the variable is in use, if no complaints I can safely remove the declaration. Also, OPTION _EXPLICIT removes the possibility of typos in variable names, the source of many, MANY, a sleepless night debugging. I highly suggest always using OPTION _EXPLICIT as your first line of code. In fact, I wish the IDE had an option to enable this feature permanently. RE: Rotate and Scale Mesh Shape - james2464 - 11-24-2022 Very interesting. Thanks for providing this insight. I'll definitely use this. A quick test made it obvious how helpful it can be. RE: Rotate and Scale Mesh Shape - mnrvovrfc - 11-24-2022 Some people don't like things imposed on them; this is well said for many that were very used to GW-BASIC or QBasic quirks and refuse to change their habits "because it doesn't let me run faster". When QuickBASIC came out, a lot of users of interpreted BASIC didn't adopt it because they absolutely hated type sigils, including the dollar sign, including to decorate the string functions. They sort of won their way in Freebasic but to their chagrin, "OPTION EXPLICIT" isn't necessary with the "default" language mode of that system. Those older programmers even turned up their noses at the subprograms instead of "DEF FN" and "GOSUB... RETURN", and at "SELECT CASE... END SELECT" instead of "ON... GOSUB/GOTO" although flaws were emphasized about the older constructs. QBasic became popular such that there are still people preferring to pass on Freebasic because "QB" language mode isn't recommended anymore for new programs, and they might be passing by QB64(PE) for other reasons making them suspicious. Well, it could include a person trying to do a complex calculation. However, if the programming system doesn't let him/her start variables wherever he/she wants, at the risk of the final result being wrong, or zero when he/she didn't expect it, then he/she isn't even going to touch it. "I just want my program to run" could include using the older constructs that QB64(PE) still supports but were either eschewed or modified by other BASIC dialects. There are an awful lot of programs out there relying on implicit variable creation, on "FOR... NEXT" loops doing what should be left instead to "_DELAY", on arrays that begin at subscript zero, on the "default" type being single-precision and many other things, and even on the default screen being 80 characters across by 25 lines. The "OPTION _EXPLICIT" will always be a choice made by the programmer. It will be his/her choice if he/she wants to track down typos but keeps blaming the product "for being stupid". Yes I had this happen to me programming in BASIC and Lua. I militantly insist in the version of the Lua interpreter directly from the Brazillian original programmers and their website, not these other spins obviously adding OOP and making sure "everything" has to be declared. But that is just me. I use "OPTION _EXPLICIT" with programs in QB64 because I'm trying to recover from that impulsive nature. Also it's a good idea when sharing programs on this forum to help new people understand the concepts better. RE: Rotate and Scale Mesh Shape - TerryRitchie - 11-24-2022 I never understood why new concepts and commands are sometimes looked upon as changing the old ways, especially for something useful like OPTION _EXPLICIT. I use it because it makes coding easier. The first time I encountered a high-level language that forced variable declaration (Turbo Pascal 3.01) I was hooked. It's just a no-brainer to have such a mechanism in place in my opinion of course. RE: Rotate and Scale Mesh Shape - mnrvovrfc - 11-25-2022 (11-24-2022, 11:33 PM)TerryRitchie Wrote: I never understood why new concepts and commands are sometimes looked upon as changing the old ways, especially for something useful like OPTION _EXPLICIT.LOL you almost detected that "Unknown identifier" was my favorite error message from that compiler in high school. RE: Rotate and Scale Mesh Shape - King Mocker - 11-25-2022 I've done another one. Similar to the first one but subtly different. It has an interesting effect when bouncing off the edges when the speed is increased, and when the number of points is changed. Code: (Select All) Option _Explicit RE: Rotate and Scale Mesh Shape - bplus - 11-25-2022 Interesting ball design. RE: Rotate and Scale Mesh Shape - SMcNeill - 11-25-2022 (11-24-2022, 05:35 PM)King Mocker Wrote: Just curious,,doesn't _Keyhit use the same key press repeat delay that Inkey$ uses? Basic answer: numbers are faster than strings. k isn't = ucase$(inkey$) as you assert above. You'd need k = ASC(ucase$(inkey$)) to come close to the right answer. (I say CLOSE, because it doesn't deal with extended inkey$ values, such as the arrow keys.) A true equivalent would be: Code: (Select All) Do If you run the above, you'll see there's STILL a difference between the _keyhit value and what we've translated for our inkey$ value -- _KEYHIT can give us both an UP and DOWN code, while INKEY$ just tells us when a key is pressed DOWN. ^ And that's the differences in the two in a nutshell. RE: Rotate and Scale Mesh Shape - SMcNeill - 11-25-2022 (11-24-2022, 11:33 PM)TerryRitchie Wrote: I never understood why new concepts and commands are sometimes looked upon as changing the old ways, especially for something useful like OPTION _EXPLICIT. Option _Explicit!! HSSSSSS!!! EVIL!! All kidding aside, me and Option _Explicit just aren't compatible. It's not that I'm against learning new ways; it's just that it doesn't suit my coding style with the rules it enforces. Where me and Option _Explicit have our irreconcilable differences comes from this type of code: Code: (Select All) SUB whatever Since QB64 requires $INLCUDE code to be broken down into two modules -- *.BI and *.BM -- I usually tend to try and get around this with a simple SHARED statement when all I need to do is share a few variables between my library's subs and functions. Option _Explicit, however, doesn't think that SHARED inside a sub/function counts as a valid declaration for the variable type in question. It wants you to DIM x, y, z inside the main module, before it ever shows up in the subs or functions... ...and that kind of defeats the whole purpose of trying to use SHARED to reduce $INCLUDE files down to a single file, rather than having two of them. Somehow, it just seems kind of silly to me to have this for "My_Example_Library.BI", just so it'll stay valid with Option _Explicit: Code: (Select All) DIM x, y, z Personally, I've just came to the conclusion that me and it just aren't meant to work together. |