02-18-2023, 09:41 PM
@QB64 community, @QB64 developers, @NasaCow
about this QB64 code
after copying and pasting this code into QB64 I have got an "OK" while I was expecting an Error Alert!
Why does QB64 compiler accept the declaration of array with variable as index delimiter?
On running it is clear why line 10 and line 20 give the same result as output.
Waiting your opinions...
about this QB64 code
Code: (Select All)
OPTION _EXPLICIT
TYPE Test
X AS INTEGER
y AS INTEGER
z AS STRING
END TYPE
TYPE UID
ID AS INTEGER
END TYPE
DIM AS INTEGER abc(1 TO 4)
DIM AS Test xyz(1 TO 10, abc()) '<----- ??? is it possible to use a variable into declaration of an array???
' this time it is not a simple variable but it is an array just declared
abc(3) = 2
xyz(1, abc(1)).X = 5 ' this is xyz(1,0).X = 5 because abc(1) has value 0 for initialization
xyz(1, abc(2)).y = 3
10 PRINT xyz(1, abc(1)).X ' this gives 5 a result because the xyz(1,0).X has been set to 5, abc(1) = 0
PRINT xyz(1, abc(2)).y
PRINT abc(3)
20 PRINT xyz(1, abc(4)).X ' this gives 5 as result because the xyz(1,0).X has been set to 5, abc(4) = 0
after copying and pasting this code into QB64 I have got an "OK" while I was expecting an Error Alert!
Why does QB64 compiler accept the declaration of array with variable as index delimiter?
On running it is clear why line 10 and line 20 give the same result as output.
Waiting your opinions...