Trying to compile v5.119 source now causes crash?

Previous topic - Next topic

bigsofty

Trying to get back up to speed. OK I've reduced this to its base error... I think?

Well, a program that used to compile and run fine, now crashes...

I have a function that loads some data when a filename is passed to it.

If I use the following in the main program...

Code (glbasic) Select
GLOBAL lastfont = addfont("fnt_test")

The program crashes when run, without a compile error.

So I reduced the "addfont()" code to one line that seemed to be causing the crash...

Code (glbasic) Select
FUNCTION addfont: filename$ // Create a new font
INIOPEN filename$+".ini" <-------------------------- If I remove this line it does not crash?
ENDFUNCTION


As I said, this used to work, the .exe is still in the folder from the last v5.119 compiler and it runs. The latest compiler seems to be not allowing this?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Moru

This is due to the line

Code (glbasic) Select
GLOBAL lastfont = addfont("fnt_test")

Never declare a variable and call a function to initialize it on the same line, break it into two lines:

Code (glbasic) Select
GLOBAL lastfont
lastfont = addfont("fnt_test")

Kitty Hello

Right. GLOBAL a=function() is bad!
The code is getting called _before_ any GLBasic initialization is done, thus it breaks with some internal functions. INIOPEN is one.

bigsofty

OK, thanks for the quick heads up guys.   

Some times I get a little carried away with all the various methods of manipulating types/vars GLB has... :whistle:

Possibly worth adding this to the syntax check parsing though, as it compiles fine?

Thanks again!  :good:
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Moru

He removed everything until he found out where it crashed, that was the only line he could leave in there to still have the crash :)