How to redim an array that represents a field of a structure?

Solution Available
John K.
Bacau,

Sep 26, 2011
55 Posts

1  |  0  

Re: How to redim an array that represents a field of a structure?

Hi there! I'm willing to redim an array of bytes that is a field of a structure with some other fields. But I can't! Let's say the structure is DiscStruct and I use the following command to redim the field abData[1]: ReDim DiscStruct.abData [20]. But no use! The compiler doesn't return any error but the array's dimension remains unchanged! How come? Can anyone please tell me where am I wrong?

DrATEasy (Ron Y.)
Mission Viejo, CA

Sep 26, 2011
369 Posts

0  |  0  

Re: How to redim an array that represents a field of a structure?

Structure has a fixed size that cannot be changed (similar to C++). You can define the structure member/field as a variant type:

structA
{
    vr : variant  ! will hold the array
}

stA: structA
al : long[1]

! initialize as array field with one element
stA.vr=al

! assign a value to the array
stA.vr[0]=120
print  stA.vr[0]

! redim to 100 elements
redim al[100]
al=stA.vr ! preserve the values
stA.vr=al  ! will set the variant to hold 100 elements



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]