Author Topic: can we have arrays in udt (user defined types)?  (Read 2781 times)

0 Members and 1 Guest are viewing this topic.

Offline blametroi

  • Newbie
  • Posts: 26
    • View Profile
can we have arrays in udt (user defined types)?
« on: December 28, 2018, 10:23:50 am »
More early steps with syntax. In my earlier question one structure I defined from the Windows API included the FileTime. Microsoft defines it as a pair of DWORDs and provides a conversion API call to turn it into something readable. As I was experimenting I tried to declare an array of unsigned bytes inside my structure and couldn't find a valid syntax.

Code: QB64: [Select]
  1. DIM ubFileTime(8) AS _UNSIGNED _BYTE
  2.  
  3. TYPE FileTime1
  4.     ftlow AS LONG
  5.     fthigh AS LONG
  6.  
  7. Type FileTime2
  8.     ubFt(8) as _unsigned _byte
  9.  
  10.  

The line
Code: QB64: [Select]
is flagged as an error with "expected variable name as type or end type".

One way I came up with to get byte level access was to define a fixed length string and use mid$ to pluck out bytes, but is there a better or more idiomatic way to do this?

Thanks.


Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: can we have arrays in udt (user defined types)?
« Reply #1 on: December 28, 2018, 11:41:08 am »
Even after intense lobbing the answer is 'NO', and probably not ever. :(
but there is variable length strings available now in UDTs, which with a bit of work can be used as arrays.
Granted after becoming radioactive I only have a half-life!

Offline blametroi

  • Newbie
  • Posts: 26
    • View Profile
Re: can we have arrays in udt (user defined types)?
« Reply #2 on: December 28, 2018, 11:56:46 am »
As long as I can accomplish what I need to, I'm OK with using strings, I just want to make sure I'm not missing something obvious.

I also need to investigate _OFFSET at some point ...