Code: Select all
Option Base 0
...
public txPayload() as byte byref
...
txPayload(0) = x
The value of txPayload varies at run-time.
Code: Select all
Option Base 0
...
public txPayload() as byte byref
...
txPayload(0) = x
The Option Base directive only affects the number of elements that are allocated for an array whose lower bound is not specified when the array is defined. In all other cases, the lower bound of an array of elements is taken to be 1.stevech wrote:txPayload is supposed to be a pointer to a byte array with the first element being 0
Code: Select all
Public txPayload() as Byte ByRef
Dim array1(0 to 19) as Byte
Dim array2(-5 to 14) as Byte
Dim x as Byte
Sub Main()
txPayload.DataAddress = array1.DataAddress
txPayload(1) = x
txPayload.DataAddress = array2.DataAddress
txPayload(1) = x
End Sub
Code: Select all
static uint8_t mzv_array1[20];
static uint8_t mzv_array2[20];
static uint8_t mzv_x;
uint8_t *zv_txPayload;
void
zf_Main(void)
{
zv_txPayload = (uint8_t *)(uint16_t)mzv_array1;
zv_txPayload[1 - 1] = mzv_x;
zv_txPayload = (uint8_t *)(uint16_t)mzv_array2;
zv_txPayload[1 - 1] = mzv_x;
}
I recall in VB6, Option Base 0 meant 0 is the index of the first element. So the ByRef (pointer) would use the same convention (base 0), it seemed to me.The Option Base directive is provided to allow you
to specify that the default array base is either 0 or 1...