Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why element size is not 2?
#8
(04-23-2023, 11:57 AM)Petr Wrote:
Code: (Select All)
Type snd1
    l As Integer
    r As Integer
End Type

Type snd2
    l As _Unsigned _Byte
    r As _Unsigned _Byte
End Type


ReDim s(0) As snd2 '1
ReDim s(0) As snd1 '2

Print Len(s(0).l) 'expected is 2

Are you trying to do an "union" type like in C? :O

Why are you trying to redimension the same array only to change the types of the same fields?

Maybe you already know but you have to use _MEM on a variable which is more than one byte in size, and you need to extract it byte by byte or something else. OK I saw the second post here...

Be glad that "Integer" will always be 2 bytes in anything directly compatible with QuickBASIC and QBasic. Because in Freebasic they decided to throw it out of whack. For that language many programs for QBasic would have to be rewritten to change from "As Integer" to "As Short" if the programmer really meant 2-byte integer.
Reply


Messages In This Thread
Why element size is not 2? - by Petr - 04-23-2023, 11:57 AM
RE: Why element size is not 2? - by Petr - 04-23-2023, 01:26 PM
RE: Why element size is not 2? - by SMcNeill - 04-23-2023, 01:45 PM
RE: Why element size is not 2? - by bplus - 04-23-2023, 02:22 PM
RE: Why element size is not 2? - by bplus - 04-23-2023, 02:30 PM
RE: Why element size is not 2? - by Petr - 04-23-2023, 03:31 PM
RE: Why element size is not 2? - by bplus - 04-23-2023, 03:49 PM
RE: Why element size is not 2? - by mnrvovrfc - 04-23-2023, 04:09 PM
RE: Why element size is not 2? - by bplus - 04-23-2023, 05:56 PM
RE: Why element size is not 2? - by SMcNeill - 04-23-2023, 06:15 PM



Users browsing this thread: 4 Guest(s)