B4J Question Detect variable names collition?

Mashiane

Expert
Licensed User
Longtime User
Hi there

Is there a way for the IDE to indicate when you are creating a Sub routine and then use Dim if your variable was already declared in Class_Globals? I know currently it does pick up that its declared differently, but is it possible to set something on that will warn that such a variable has been declared already.

I'm asking because I have noted that the reason my code malfunctions at times is because of this methodolody I'm using where I declare variables in class globals and then do same inside Sub routines. It seems the IDE will prioritise the Class_Globals variables for some types of variables.

For example

B4X:
Sub Class_Globals
 Public btnCopy as Button
End Sub

Sub DoThat
  Dim btnCopy as Button
  btnCopy.Text = "Warn I have been defined in class globals"
End Sub
 

Daestrum

Expert
Licensed User
Longtime User
In your example above, if you hover over the btnCopy in the sub doThat, the ide will tell you it is a global variable.
An object (eg, button) that has been newly defined and does not appear in globals, will say local variable.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Will the btnCopy in DoThat become protected and not collide with the global declaration?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…