B4J Question Compiling problem

Bruce Axtens

Active Member
Licensed User
Longtime User
The error message

B4X:
B4J version: 4.20 (1)
Parsing code.    (0.00s)
Compiling code.    (0.02s)
Compiling layouts code.    (0.00s)
Compiling generated Java code.    Error
B4J line: 43
gSql.ExecNonQuery2(\
javac 1.8.0_65
src\b4j\example\main.java:115: error: unreachable statement
;
^
1 error

My source

B4X:
	'Non-UI application (console / server application)
#Region  Project Attributes 
	#CommandLineArgs:
	#MergeLibraries: True 
	#AdditionalJar: sqljdbc4.jar
#End Region

Sub Process_Globals
	Private gSql As SQL
	Private pCFG As Map
End Sub

Sub AppStart (Args() As String)
	pCFG.Initialize
	
	Try
		gSql.Initialize2("com.microsoft.sqlserver.jdbc.SQLServerDriver","jdbc:sqlserver://localhost:1433;" & _
			"databaseName=ResearchSanctum;","XXXXXXXXXX","YYYYYYYYYY")
	Catch
		Log(LastException.Message)
		ExitApplication2(1)
	End Try
	
	Do While True	
		Try
			Dim answer As Object = gSql.ExecQuerySingleResult("SystemTestOrg")
		Catch
			Log(LastException.Message)
		End Try
		
		If Null = answer Then
			gSql.Close
        	ExitApplication
		End If
		Dim SanctumID As Int = answer
		
		gSql.ExecNonQuery2("SystemTestOrg_01_StartUpdate ?",Array As Object(SanctumID))
		
		gSql.ExecNonQuery2("Sanctum_Merge_Org_Import ?",Array As Object(SanctumID))
		
		gSql.ExecNonQuery2("SystemTestOrg_03_FinishUpdate ?",Array As Object(SanctumID))
	Loop
	
	Do While True	
		Dim answer As Object = gSql.ExecQuerySingleResult("SystemTestPartA")
		If Null = answer Then
			gSql.Close
        	ExitApplication
		End If
		Dim SanctumID As Int = answer
		
		gSql.ExecNonQuery2("SystemTestPartA_01_StartUpdate ?",Array As Object(SanctumID))
		gSql.ExecNonQuery2("Sanctum_Merge_PartA_Import ?",Array As Object(SanctumID))
		gSql.ExecNonQuery2("SystemTestPartA_03_FinishUpdate ?",Array As Object(SanctumID))
	Loop
	
End Sub

I don't see any semicolons in the source. What's happening here?
 

stevel05

Expert
Licensed User
Longtime User
I can see two potential issues in the code, the first is that you have:

B4X:
#CommandLineArgs:

with no arguments. It may cause a problem I haven't tried it. The second and more likely related to the error message is that the first loop has no exit without exiting the app. I'm not sure if that is recognised as a valid exit for the loop. Even if it is, everything after the loop would be unreachable and would never be run.
 
Last edited:
Upvote 0

Bruce Axtens

Active Member
Licensed User
Longtime User
The second and more likely related to the error message is that the first loop has no exit without exiting the app.
That would seem to be the issue then. Having put an Exit in the If and placing the ExitApplication at the end, hinneh now everything compiles.


Thank you very much.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…