Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Data setting tutorial video!
#1
Is your code filled with blocks of variable setting or DATA statements?  Is code you wrote years ago now indecipherable to you as a result?  Suffer no longer!  Table routines and abstraction are here to save the day.

This tutorial video isn't really QB64 specific, but hopefully people will get some mileage out of it, and find ways to make their code clearer and less bulky.

Reply
#2
All I'm going to say is...

look at "QB64.BAS" out of the last SDL version. About the first 500 LOC or so have a bunch of variable declarations and/or assignments being mixed with executable statements. Compared to that, thousands of "DATA" statements is a wall that cannot be helped. It's better than using "zlib" compression like one of Dav's utilities, only for the sake of readability, but some insecure people want to make sure things cannot be read easily. Such as the ones requesting image and sound files embedded into Windows EXE's or the equivalent of the two popular Unix-like operating systems.

I'm sorry if I misled people while I said somewhere Freebasic allowed multiline strings, it doesn't, not even with its "macros". If any BASIC dialect had to support something like the "here strings" in Bash shell language, it might represent the end of readability without "REM" statements. It's because people are going to want to "pickle", to obfuscate and to do all sorts of wicked schemes with data which resides inside code.
Reply
#3
(12-03-2022, 12:12 PM)mnrvovrfc Wrote: All I'm going to say is...

look at "QB64.BAS" out of the last SDL version. About the first 500 LOC or so have a bunch of variable declarations and/or assignments being mixed with executable statements. Compared to that, thousands of "DATA" statements is a wall that cannot be helped. It's better than using "zlib" compression like one of Dav's utilities, only for the sake of readability, but some insecure people want to make sure things cannot be read easily. Such as the ones requesting image and sound files embedded into Windows EXE's or the equivalent of the two popular Unix-like operating systems.

I'm sorry if I misled people while I said somewhere Freebasic allowed multiline strings, it doesn't, not even with its "macros". If any BASIC dialect had to support something like the "here strings" in Bash shell language, it might represent the end of readability without "REM" statements. It's because people are going to want to "pickle", to obfuscate and to do all sorts of wicked schemes with data which resides inside code.

I always thought a simple command like _EMBED DATA: Label, Size would be nice.

Basic usage would be like:

_EMBED DATA: Foo, 12
ABCDEFGHIJKL
_EMBED END

The IDE would read that, start on the line below, and read the next 12 characters as a string of unformatted data and save it in a string type variable called "Foo", which you can then _MEMPUT into whatever you need it to actually go into -- an array, an image handle, a sound block... whatever.  The END block is a safety check to make certain that the ide read the proper number of bytes that you told it to.  If it's not immediately the next thing that the IDE sees after reading the number of bytes you specified, it tosses an error for you -- "Incorrect number of bytes in embeded data on line XXX".

Sure, it'd look ugly (collapsable blocks would take care of that), but it'd be a nice easy way to embed large chunks of raw data directly into a QB64 program.  Wink
Reply
#4
This all kind of misses the spirit of the video, though - which was to improve organization, clarity, and thus make development smoother and cleaner.  I'm a fan of "clean as you go" with manual tasks, and programming benefits from this as well.  If it's something you don't want other people to be able to read at all, then this topic doesn't really apply.

You're going to find that a lot of my guides and videos and stuff are directly or indirectly related to game development, since that's what I do.  Not really API stuff, utilities, etc.  This kind of abstraction is really, REALLY useful to keep track of things when developing a game!  Smile
Reply
#5
(12-03-2022, 12:44 PM)SMcNeill Wrote: I always thought a simple command like _EMBED DATA: Label, Size would be nice.
I support this. The problem is people would expect to be able to use "any" character inside the embed block, might expect an "escape" for it.

@johannhowitzer : I like your avatar! Heart
Reply
#6
(12-03-2022, 11:18 AM)johannhowitzer Wrote: Is your code filled with blocks of variable setting or DATA statements?  Is code you wrote years ago now indecipherable to you as a result?  Suffer no longer!  Table routines and abstraction are here to save the day.

This tutorial video isn't really QB64 specific, but hopefully people will get some mileage out of it, and find ways to make their code clearer and less bulky.

Go to the video!

@johannhowitzer

Quote:I'm a fan of "clean as you go"


...And I'm a fan of yours! Great to see you made your way back to the Forum. Welcome back!

I've actually uses a setting array technique for certain database files I worked with decades ago. It makes, as you stated in your video, readability sooooo much easier. I wish they would teach concepts like this in schools early on. Instead, most get students started out with small examples of programming in bulk, which plants a bad seed for future much larger endeavors.

Nice vid, too. Did you know you could also embed your vids here, so they play on the page? Just click that 'film strip' icon in the tool bar and paste in the URL.

Pete
Reply
#7
Thanks for the tip, edited the OP.
Reply




Users browsing this thread: 1 Guest(s)