About variable name case sensitive?

New to FreeBASIC? Post your questions here.
Post Reply
PeterHu
Posts: 146
Joined: Jul 24, 2022 4:57

About variable name case sensitive?

Post by PeterHu »

Just learned from github,here is a piece of code :

Code: Select all

[b]Const RADIUS = 10[/b]
Const PEN = 10
Declare Function main_procedure() As Integer

main_procedure()

Function main_procedure() As Integer
	Dim As String canvas(Radius * 5, Radius * 5)
	Dim As String foreground = "0 "
	Dim As String background = ". "
	[b]Const As Integer Radius = Radius[/b]
	...
	return 0
End Function
For scope variable Radius and global const variable RADIUS,given

Code: Select all

const as integer Radius=RADIUS
would compile.How is this possible,isn't there a duplicate variable declaration?

Thanks in advance for any help.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: About variable name case sensitive?

Post by fxm »

It would seem that as long as a constant's initialization value (and its data-type) is not changed, this constant can be re-declared:

Code: Select all

Const c = 1
Const c = 1
Const c = c
Const c = c
This is not the case for a constant variable ('Dim As Const Integer c = 1').
PeterHu
Posts: 146
Joined: Jul 24, 2022 4:57

Re: About variable name case sensitive?

Post by PeterHu »

Thanks a lot.
Post Reply