S sorex Expert Licensed User Longtime User Jan 26, 2014 #1 Hello, In several languages I can do this: B4X: If myvar="" Then showalert:Exit the B4A precompile pass doesn't give an error on this but during the java compile it gives this error B4X: src\b4a\example\main.java:323: error: break outside switch or loop if (true) break; ^ 1 error using exit sub also fails. ain't there a way to get this working without all the extra linefeeds and end if's ?
Hello, In several languages I can do this: B4X: If myvar="" Then showalert:Exit the B4A precompile pass doesn't give an error on this but during the java compile it gives this error B4X: src\b4a\example\main.java:323: error: break outside switch or loop if (true) break; ^ 1 error using exit sub also fails. ain't there a way to get this working without all the extra linefeeds and end if's ?
S sorex Expert Licensed User Longtime User Jan 26, 2014 #2 ok, it seems that I had to use return instead of the exit method like in VB and others. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jan 26, 2014 #3 In B4A/J the following code: B4X: If myvar="" Then showalert:Exit Is equivalent to: B4X: If myvar = "" Then showalert Exit 'not inside the if condition. You cannot combine two statements this way. You will need to write: B4X: If myvar="" Then showalert return End If Upvote 0
In B4A/J the following code: B4X: If myvar="" Then showalert:Exit Is equivalent to: B4X: If myvar = "" Then showalert Exit 'not inside the if condition. You cannot combine two statements this way. You will need to write: B4X: If myvar="" Then showalert return End If
S sorex Expert Licensed User Longtime User Jan 26, 2014 #4 Indeed, I noticed it when my 2nd check didn't work. Upvote 0