Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sample program using the new _Files$ function
#15
One is a variable.  The other is an User Defined Type.

You can Dim b as _bit * 12, and this is going to be very easy to understand and process.  You need 2 bytes to hold those 12 bits, so you store it as an INTEGER, and then AND &B111111111111 the value to make certain that you're only keeping 12 bits out of the total 16.   (Or you shift left 4 times and then shift back right 4 times, for the same type reslt.)

But with a UDT, you have to account for other possibilites such as:

TYPE foo
    b as _BIT
    c AS _BIT
    d as _BYTE
    e as _BIT
    f AS _FLOAT
END TYPE

Now, the argument suddenly explodes.   What size should that data type be?

Should the compiler somehow optomize those 3 bits so they all take up the same byte?
Should the first two bits belong in the same byte, while the 3rd bit should be in a byte by itself?
Should all those bits be stored in individual bytes?
Heck, maybe there should be an option to specify how the user expects them to be!!

TYPE foo
    b as _PACKED _BIT 1 OF _BYTE 1
    c AS _PACKED _BIT 2 OF _BYTE 1
    d as _BYTE
    e as PACKED _BIT 3 OF _BYTE 1
    f AS _FLOAT
END TYPE

Golly, wouldn't that be nice!

Well..... I guess it could be...  But the overhead in processing such a thing....  And you're now checking *EVERY* UDT to see if this extended syntax applies to it...  And you're packing data, and unpacking data, and tracking data positions, and OH MY GAWD!!  Just what the BLEEP did you just do???   This certainly isn't BASIC anymore!!   AHHHHHHH!!!!

Big Grin

See the simple difference in the two?
Reply


Messages In This Thread
RE: Sample program using the new _Files$ function - by SMcNeill - 02-07-2024, 05:38 AM



Users browsing this thread: 1 Guest(s)