[Gambas-user] Arrays of Structs - how to - and curious debug message

Benoît Minisini g4mba5 at gmail.com
Fri Jun 11 15:55:55 CEST 2021


Le 11/06/2021 à 02:34, John Anderson a écrit :
> 
> Yes, I did the description as per your wiki page.  I tried that first, 
> but it says it's not a real array.  But throwing all caution to wind I 
> Did 'MyBigArray2[200] as Struct MyStruct.'
> 
> Now Object.SizeOf(MyBigArray2) has a size of 40 bytes (I know it is just 
> an object).   Then I started to try different ways but I was just being 
> stupid.
> 
> C code needs pointer to that array PLUS size of the array it's getting  
> (ByRef MyBigArray2, tsize)... I guess I have to calc final array size in 
> bytes as Object.SizeOf(MyStruct) * MyBigArray2.Count?
> 
> How to copy array of struct contents Gambas way? (not pointers, 
> contents).  I'm sorry if its in docs, I don't see it yet.  I know I can 
> copy arrays of Gambas [] types with .Copy method, but I don't think that 
> works with array of struct? (If I try Copy with array of struct , it 
> comes back "Copy Unknown Method error).
> 
> Attached, compressed project (with known error) will emit errors upon 
> completion if a data breakpoint is set, but will show NO errors when 
> breakpoint NOT set.  That could be a real problem - is it supposed to 
> work that way?  If it might be a bug, I'll post on bug tracker when its 
> login works again.
> 
> -John
> 

OK, I have analyzed the problem: the structure assignment is buggy, it 
does not handle all cases. Hopefully the memory stream does, so it 
should be a matter of code refactoring.

If you don't know what is a memory stream in Gambas, I suggest you look 
it, you can use it as a workaround for the current problem (Look at OPEN 
MEMORY in the documentation).

As for the breakpoint problem, let's see that later.

Regards,

-- 
Benoît Minisini


More information about the User mailing list