Author Topic: Compilation Fail when loading Multidiminsonal array  (Read 2432 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Compilation Fail when loading Multidiminsonal array
« 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.
« Last Edit: June 29, 2019, 03:46:25 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Compilation Fail
« Reply #1 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.
« Last Edit: June 29, 2019, 04:01:46 am by Petr »