Is this a bug in FB?

For other topics related to the FreeBASIC project or its community.
ike
Posts: 383
Joined: Jan 17, 2011 18:59

Is this a bug in FB?

Postby ike » Feb 01, 2017 15:49

Code: Select all


namespace ORDERPARTS
   DIM as String sORD1, sORD2
end namespace

dim as string s1, s2

ORDERPARTS.sORD1 = "abc"
ORDERPARTS.sORD2 = "haha"

s1 = ORDERPARTS.sORD1
s2 = ORDERPARTS.sORD2

if len(s1) <> len(s2) then  ' this works
'if len(s1) <> len(ORDERPARTS.sORD2) then       ' this does not -> variable sORD2 not declared???
beep
end if


MrSwiss
Posts: 3124
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Is this a bug in FB?

Postby MrSwiss » Feb 01, 2017 16:00

No, not a BUG. Replace *namespace* with *Type*, and all works, as expected.

Code: Select all

Type UDT
    As String ..., ...
End Type

Dim as UDT myUDT

'use further:
myUDT.StringName
ike
Posts: 383
Joined: Jan 17, 2011 18:59

Re: Is this a bug in FB?

Postby ike » Feb 01, 2017 16:45

It works in double (())


Code: Select all



NAMESPACE ORDERPARTS
   DIM as String sORD1
   DIM as String sORD2
end NAMESPACE

ORDERPARTS.sORD1 = "abc"
ORDERPARTS.sORD2 = "haha"

's1 = ORDERPARTS.sORD1
's2 = ORDERPARTS.sORD2

? ORDERPARTS.sORD2

? "LEN=", LEN((ORDERPARTS.sORD2))

dkl
Site Admin
Posts: 3207
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Is this a bug in FB?

Postby dkl » Feb 01, 2017 16:50

Yeah, there is a known problem with len()/sizeof() and namespaces. Due to a parser bug, the namespace prefix is ignored, then there is a "variable not declared" error.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 6 guests