Problem using $Include-files (bug??)

Windows specific questions.
BasicJan
Posts: 46
Joined: Aug 30, 2005 20:09
Location: Netherlands

Problem using $Include-files (bug??)

Postby BasicJan » Aug 12, 2006 20:18

Next program exists out of three different files.
= Compiling and running with QuickBasic works fine
= Compiling and running with FreeBasic version 0.15 works fine
= Compiling and running with FreeBasic version 0.16 causes problems.
The array DemoText seems to be empty when one tries to print a text.

(It is not possible to move the DIM DemoText-statement to LIBRARY.BI. In the original program there is also a MAINPROG.BI-file containing lots of other declarations which must preceed the DIM DemoText-statement.)

********** FILE: MAINPROG.BAS **********

'$INCLUDE: 'LIBRARY.BI'

'########## Necessary for LIBRARY ##########
DIM DemoText(25) AS DemoTextType 'Different demotexts
'########## Necessary for LIBRARY ##########

DIM LvContinue
DIM LvDemoTextNumber

InitDemoTexts

LvContinue=TRUE
CLS
DO WHILE LvContinue
LOCATE 1,5
INPUT "Enter demotext-number: ",LvDemoTextNumber
IF LvDemoTextNumber>0 THEN
PrintDemoText(LvDemoTextNumber)
ELSE
LvContinue=FALSE
END IF
LOOP

SYSTEM

********** FILE: LIBRARY.BAS **********

'$INCLUDE: 'LIBRARY.BI'

SUB InitDemoTexts
'Initialise all different demotexts
DIM LvCounter

FOR LvCounter=1 TO UBOUND(DemoText)
DemoText(LvCounter).Nbr=LvCounter
DemoText(LvCounter).Text="Demotext "+STR$(LvCounter)
NEXT LvCounter
END SUB

SUB PrintDemoText(DemoTextNbr)
'Print demotext
DIM LvCounter
DIM LvIndex

LvIndex=0
FOR LvCounter=1 TO UBOUND(DemoText)
IF DemoText(LvCounter).Nbr=DemoTextNbr THEN
LvIndex=LvCounter
EXIT FOR
END IF
NEXT LvCounter
LOCATE 5,5
IF LvIndex=0 THEN
PRINT "Demotext-number not found"
ELSE
PRINT DemoText(LvCounter).Text
END IF

END SUB

********** FILE: LIBRARY.BI **********

' $DYNAMIC Set arrays dynamic for better use of memory
DEFINT A-Z
DEFINT a-z

TYPE DemoTextType
Nbr AS INTEGER 'Demotext-number
Text AS STRING*78 'Demotext
END TYPE

CONST TRUE=-1
CONST FALSE=NOT TRUE

COMMON SHARED DemoText() AS DemoTextType 'Different demotexts

DECLARE SUB InitDemoTexts()
DECLARE SUB PrintDemoText(DemoTextNbr)
counting_pine
Site Admin
Posts: 6229
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Postby counting_pine » Aug 12, 2006 22:00

I think this is because '$include is deprecated and has been removed from FreeBASIC. Unfortunately, because the line is a comment, FBC doesn't inform you of any error.

Use this syntax instead: #include "myfile.bas"

I think other comment-encoded statements like '$dynamic are being phased out, but I think this one is still in. I suggest changing it to "option dynamic" to make sure you don't have a similar problem with that later on.
D.J.Peters
Posts: 8189
Joined: May 28, 2005 3:28
Contact:

Postby D.J.Peters » Aug 12, 2006 22:01

#include "xyz.bi"
#inclib "xyz"
v1ctor
Site Admin
Posts: 3801
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Postby v1ctor » Aug 13, 2006 0:12

$include stills supported, only $inclib and $incpath aren't.

There were bugs with COMMON in 0.16, install 0.17 over it.

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 4 guests