Android Question Unused variable when it is used.

Bryan

Member
Licensed User
Longtime User
This is very strange. It doesn't matter where I declare it , it always shows up underlined in green as an unused variable.

Dim StatusIn as Boolean

I put it in globals it shows as being unused. I put it in the beginning of the
Activity_Create sub it shows up as being unused.
The variable is used in Activity_Create. I even changed the variable to a different name a few times and still the same thing.

If I remove the declaration of this variable then the variable (StatusIn) is red.

I noticed this trying to debug other problems I having.
I have one other Boolean variable and it is fine. It is not underlined in green.
I don't want to post all my code because it is going to be a product that will be sold on google play.
Any ideas?

Bryan
 

KMatle

Expert
Licensed User
Longtime User
b4a has some logic checks and finds out when a variable isn't used (even if you seen it and assign a value to it later in the code). This may occur in a IF... THEN... scenario when b4a thinks it will never be called/used due to a faulty logic.

Put it in globals and change (for a test) the value somewhere else (f.e. in crate without any conditions)
 
Upvote 0

Bryan

Member
Licensed User
Longtime User
Are you sure that the variable value is actually used? Not only declared? If yes then if possible please send me your project by mail (erel@basic4ppc.com).
Yes, it is actually used. Declared in globals, Used in Activity_Create. It has been removed from my code now because I'm not going to use that variable any longer. I am away from my programming computer so it will be awhile before I can get back to working with it. My project is using many classes and is getting quite large now so I will see if I can streamline it a bit and recreate the problem.
 
Upvote 0

Bryan

Member
Licensed User
Longtime User
Are you sure that the variable value is actually used? Not only declared? If yes then if possible please send me your project by mail (erel@basic4ppc.com).

Here is an example of what I am talking about. This is from the table class v1.36 that I am using. I am just going to upload an image of my screen.
 

Attachments

  • Variable_problem.png
    154.8 KB · Views: 225
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…