Author |
Topic: Initialising Structures (Read 471 times) |
|
Matt
Developer
member is offline


Gender: 
Posts: 210
|
 |
Initialising Structures
« Thread started on: Sep 25th, 2010, 05:38am » |
|
Hi, The BB4W help explains how to initialise arrays:
A%() = 1, 2, 3, 4, 5 B$() = "Alpha", "Beta", "Gamma", "Delta" C() = PI
But this doesn't seem to be the case with structures:
structure.A%() = 1, 2, 3, 4, 5 structure.B$() = "Alpha", "Beta", "Gamma", "Delta" structure.C() = PI
Is this so, or am I missing something?
Matt
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Initialising Structures
« Reply #1 on: Sep 25th, 2010, 08:32am » |
|
on Sep 25th, 2010, 05:38am, Matt wrote:The BB4W help explains how to initialise arrays: But this doesn't seem to be the case with structures: Is this so, or am I missing something? |
|
You're quite right. Arrays within structures have a different memory layout to 'regular' arrays, and none of the 'whole array' operations work with them. This is documented in the manual as follows: "Normally a structure member can be treated in exactly the same way as a simple variable of the same type. However this is not so in the case of operations on entire arrays or entire structures which cannot be used with structure members":
http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin2.html#members
It's an unfortunate consequence of the way structures were 'bolted on' to a language which wasn't originally designed with them in mind.
Richard.
|
|
Logged
|
|
|
|
|