QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Cobalt on June 28, 2019, 05:29:28 pm

Title: Compilation Fail when loading Multidiminsonal array
Post by: Cobalt on June 28, 2019, 05:29:28 pm
Why is this not allowed?
Code: [Select]
DIM SHARED Leaders(9, 5) AS STRING * 20
OPEN "names.lbx" FOR BINARY AS #1
SEEK #1, 548
GET #1, , Leaders()
FOR i%% = 0 TO 5
 PRINT Leaders(0, i%%)
NEXT i%%

throws the following:
In file included from qbx.cpp:2162:0:
..\\temp\\main.txt: In function 'void QBMAIN(void*)':
..\\temp\\main.txt:13:110: error: lvalue required as unary '&' operand
compilation terminated due to -Wfatal-errors.
Title: Re: Compilation Fail
Post by: Petr on June 29, 2019, 03:47:42 am
Hi. I  do not know, why your code works not, but if you need working on it, you can use this way:

Code: [Select]
DIM SHARED Leaders(9, 5) AS STRING * 20
OPEN "names.lbx" FOR BINARY AS #1
SEEK #1, 548
rec$ = SPACE$(20)
FOR read_it = 0 TO 5
    GET #1, , rec$
    Leaders(0, read_it) = rec$
NEXT read_it
FOR i%% = 0 TO 5
    PRINT Leaders(0, i%%)
NEXT i%%


I try the same as in your code with PUT (for creating Leaders file) also with bug message.

Code: [Select]
DIM text(10, 10) AS STRING * 20
FOR x = 0 TO 10
    FOR y = 0 TO 10
        FOR text = 1 TO INT(19 * RND)
            t$ = t$ + CHR$(32 + RND * 96)
        NEXT text
        text(x, y) = t$
        t$ = ""
NEXT y, x

OPEN "names.lbx" FOR BINARY AS #2
PUT #2, , text$()
CLOSE 2

Error message:

In file included from qbx.cpp:2171:
..\\temp\\main.txt: In function 'void QBMAIN(void*)':
..\\temp\\main.txt:86:107: error: lvalue required as unary '&' operand
 sub_put( 2 ,NULL,byte_element((uint64)(&(qbs_new_fixed(&((uint8*)(__ARRAY_STRING20_TEXT[0]))[(0)*20],20,1))),(20*(__ARRAY_STRING20_TEXT[2]&1)*__ARRAY_STRING20_TEXT[5]*__ARRAY_STRING20_TEXT[9])-(20*(0)),byte_element_7),0);
                                                                                                           ^
compilation terminated due to -Wfatal-errors.

This errors do GET and PUT. If this are commented, then compilation run.