Wish Warnings for code that won't do anything

Similar threads

Games [XUI2D] Example Pack
B4A Code Snippet Advertising id
B4A Question New Android SDK - Warning.
B4A Tutorial Compiler Warnings
B4A Tutorial [B4X] [XUI] Msgbox

JdV

Active Member
Licensed User
Hi

It would be good if the IDE could report warnings for code that won't anything and which doesn't cause any errors.

For example, the 'MyString.Replace' doesn't replace the word 'world' with 'everyone' in the following piece of code:

B4X:
Dim MyString As String
MyString = "Hello world"
MyString.Replace("world", "everyone")
Log(MyString)
These warnings could be similar to the way that the IDE reports variables that are never assigned values or subs that are never called.

Regards

Joe
 

MarkusR

Well-Known Member
Licensed User
or if the return is not used it make a replace in the string, would also be good
 

DonManfred

Expert
Licensed User
It is not a bug, it is a programming mistake.

Dim MyString As String
MyString = "Hello world"
MyString.Replace("world", "everyone") ' Replace returns a new String
Log(MyString)
Correct code
B4X:
Dim MyString As String
MyString = "Hello world"
MyString = MyString.Replace("world", "everyone")
Log(MyString)
 

JdV

Active Member
Licensed User
or if the return is not used it make a replace in the string, would also be good
That would work for string example but for the following code it's not obvious what to do with the result:
B4X:
Dim b As Bitmap
b.Initialize(File.DirAssets, "test.png")
b.GetPixel(0,0)
 

DonManfred

Expert
Licensed User

MarkusR

Well-Known Member
Licensed User
yes agree, a warning would be great in this case.
 
Top