F frla Member Licensed User Longtime User Aug 8, 2012 #1 I wish that if it detects ; at the end of the line it will warn me about it... I work a lot also with C# and Delphi (Pascal) and sometimes I add the ; as pure routine. I would also like to get some kind of warning if I happened to use + instead of &.. now I just stare at the code when I release that the correct character is &... Otherwise.. great product! Love it!
I wish that if it detects ; at the end of the line it will warn me about it... I work a lot also with C# and Delphi (Pascal) and sometimes I add the ; as pure routine. I would also like to get some kind of warning if I happened to use + instead of &.. now I just stare at the code when I release that the correct character is &... Otherwise.. great product! Love it!
Vader Well-Known Member Licensed User Longtime User Jan 13, 2013 #2 It would also be nice to have the comiler warn about things like single-character variable names (i, j, k etc) as they don't follow any documented coding conventions. And, if people want to ignore warnings, they should be able to turn them off.
It would also be nice to have the comiler warn about things like single-character variable names (i, j, k etc) as they don't follow any documented coding conventions. And, if people want to ignore warnings, they should be able to turn them off.
G gawie007 Member Licensed User Longtime User May 9, 2013 #3 2.70 Beta Warning 2 Hi Erel, I am not sure if this means anything but I have created a method in a class that returns a string. The variables vStr and vLen are used in the method. The following code returns a warning 2, "Not all code paths return a value" on the line Sub Adj... Code: Copy Sub AdjustStringLength(vStr As String, vLen as Int) As String Dim retStr As String ... retStr = "abc" Return retStr if I change this to(which I think was my original code): Code: Copy Sub AdjustStringLength(vStr As String, vLen as Int) Dim retStr As String ... retStr = "abc" Return retStr The last line, "Return retStr" has a warning 3, "Return Type(in Sub signature) should be set explicitly." which is what I tried to do in the first section of code. Kind regards Gavin Last edited: May 9, 2013
2.70 Beta Warning 2 Hi Erel, I am not sure if this means anything but I have created a method in a class that returns a string. The variables vStr and vLen are used in the method. The following code returns a warning 2, "Not all code paths return a value" on the line Sub Adj... Code: Copy Sub AdjustStringLength(vStr As String, vLen as Int) As String Dim retStr As String ... retStr = "abc" Return retStr if I change this to(which I think was my original code): Code: Copy Sub AdjustStringLength(vStr As String, vLen as Int) Dim retStr As String ... retStr = "abc" Return retStr The last line, "Return retStr" has a warning 3, "Return Type(in Sub signature) should be set explicitly." which is what I tried to do in the first section of code. Kind regards Gavin
agraham Expert Licensed User Longtime User May 9, 2013 #4 I can't duplicate this. Are you sure your first example didn't have some code after the "Return"? EDIT:- Actually that would be an unreachable code error. The key may be in the lines "..." that you didn't post. Last edited: May 9, 2013
I can't duplicate this. Are you sure your first example didn't have some code after the "Return"? EDIT:- Actually that would be an unreachable code error. The key may be in the lines "..." that you didn't post.
Erel B4X founder Staff member Licensed User Longtime User May 9, 2013 #5 And, if people want to ignore warnings, they should be able to turn them off. Click to expand... Warnings can be disabled easily. See the warnings tutorial.
And, if people want to ignore warnings, they should be able to turn them off. Click to expand... Warnings can be disabled easily. See the warnings tutorial.
G gawie007 Member Licensed User Longtime User May 9, 2013 #6 Problem solved Thank's AGraham, Schoolboy error - had it nested in my outside IF statement. Return MUST BE THE LAST STATEMENT! Too many early mornings driving past you to customers in Liverpool & a 3 year old girl that doesn't sleep too well! Thank's Erel, There is a bug that was actually a Unit test that passed! I really thought I was onto something and wanted to contribute. Sorry for wasting your time over this busy period! Kind regards Gavin
Problem solved Thank's AGraham, Schoolboy error - had it nested in my outside IF statement. Return MUST BE THE LAST STATEMENT! Too many early mornings driving past you to customers in Liverpool & a 3 year old girl that doesn't sleep too well! Thank's Erel, There is a bug that was actually a Unit test that passed! I really thought I was onto something and wanted to contribute. Sorry for wasting your time over this busy period! Kind regards Gavin
agraham Expert Licensed User Longtime User May 9, 2013 #7 gawie007 said: Return MUST BE THE LAST STATEMENT! Click to expand... That is not strictly true. As long as all the paths the code could take include a Return you can have multiple Returns embedded in loops and If statements as long as every possibility Returns a value. Mind you it is very common to need a "catch-all" Return at the end of a Sub to complete the requirement for all paths to return a value.
gawie007 said: Return MUST BE THE LAST STATEMENT! Click to expand... That is not strictly true. As long as all the paths the code could take include a Return you can have multiple Returns embedded in loops and If statements as long as every possibility Returns a value. Mind you it is very common to need a "catch-all" Return at the end of a Sub to complete the requirement for all paths to return a value.
Erel B4X founder Staff member Licensed User Longtime User May 9, 2013 #8 No problem at all. Also note that this code will not raise any warning: Code: Copy Sub S1 As Int If SomeVar = 1 Then Return 1 Else Return 23 End If End Sub
No problem at all. Also note that this code will not raise any warning: Code: Copy Sub S1 As Int If SomeVar = 1 Then Return 1 Else Return 23 End If End Sub
G gawie007 Member Licensed User Longtime User May 9, 2013 #10 You are both right, I have used these in the past - I think that is what threw me off. My error is the If statement I was using (trying to trap errors inside the class): Code: Copy Sub .. If vStr <> Null Then ... Return retStr End If End Sub This leaves this with the possibility of no value being returned i.e. vStr = Null Solution (Not open ended): Code: Copy Sub .. If vStr <> Null Then ... retStr = "notNull" Return retStr Else retStr = "isNull" Return retStr End If End Sub They say you are never too old to learn! What a basic mistake! Anyways, on a lighter note, thank you guys for the "Return statement tutorial". Keep up the GREAT work!!! ....and I will still try to contribute in some little ways. Cheers Gavin
You are both right, I have used these in the past - I think that is what threw me off. My error is the If statement I was using (trying to trap errors inside the class): Code: Copy Sub .. If vStr <> Null Then ... Return retStr End If End Sub This leaves this with the possibility of no value being returned i.e. vStr = Null Solution (Not open ended): Code: Copy Sub .. If vStr <> Null Then ... retStr = "notNull" Return retStr Else retStr = "isNull" Return retStr End If End Sub They say you are never too old to learn! What a basic mistake! Anyways, on a lighter note, thank you guys for the "Return statement tutorial". Keep up the GREAT work!!! ....and I will still try to contribute in some little ways. Cheers Gavin