QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: blametroi on December 28, 2018, 10:23:50 am

Title: can we have arrays in udt (user defined types)?
Post by: blametroi 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.

Title: Re: can we have arrays in udt (user defined types)?
Post by: Cobalt 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.
Title: Re: can we have arrays in udt (user defined types)?
Post by: blametroi 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 ...