Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interesting compile error
#6
(05-19-2025, 11:42 AM)bobalooie Wrote:
(05-19-2025, 06:31 AM)RhoSigma Wrote: Which version of QB64-PE are you using:

Quote:DIM SHARED AS STRING segment(1).

REDIM _PRESERVE segment AS STRING.

REDIM _PRESERVE segment * 57 AS STRING.

The latter two lines are completly wrong, that's not the way how array (re)dimming works. If I paste the above lines into the IDE I immediatly get syntax errors and arn't even able to start compiling the code.

4.1.0.

Yes, I see that the redim dimension is missing in what I typed. My bad, it was late for me. I didn't copy the code. In the program the dimensions are there.

Initial declaration:                     DIM SHARED AS STRING wires(20), filename, segments(1) 

Doesn't cause compiler errors:    REDIM _PRESERVE AS STRING segments(iy)

Causes compiler errors:              REDIM _PRESERVE AS STRING * 57 segments(iy)

The point was that redimming as a fixed length string resulted in the compiler errors, but the IDE didn't flag that something was amiss.

Yes, with the dimensions it looks more correct now. However, you can't REDIM a variable length string into a fixed length one. That would imply not only changing the dimensions but also the TYPE of the array. And you are correct that the IDE should warn here at least with a "Name already in use" error, so you know you can't use the same array name one time for variable and another time for fixed length strings.

However, when I try to do this here, then I still can't compile it because the IDE gets trapped into an endless loop checking the code as soon as I typed it. So here's definitly something weird going on.
Reply


Messages In This Thread
Interesting compile error - by bobalooie - 05-19-2025, 02:25 AM
RE: Interesting compile error - by RhoSigma - 05-19-2025, 06:31 AM
RE: Interesting compile error - by bobalooie - 05-19-2025, 11:42 AM
RE: Interesting compile error - by RhoSigma - 05-19-2025, 02:34 PM
RE: Interesting compile error - by hsiangch_ong - 05-19-2025, 11:32 AM
RE: Interesting compile error - by PhilOfPerth - 05-19-2025, 12:10 PM
RE: Interesting compile error - by bplus - 05-19-2025, 06:14 PM
RE: Interesting compile error - by bobalooie - 05-20-2025, 12:12 PM
RE: Interesting compile error - by bplus - 05-20-2025, 02:27 PM



Users browsing this thread: 1 Guest(s)