Sub execution breakes

Penko

Active Member
Licensed User
Longtime User
Hello there! Haven't had the chance to work under B4A 2.00 seriously and I've just started a project from scratch.

I am having weird behavior at the very beginning.

Take the following sub as example:

B4X:
Sub GetSomeData(whereMap As Map, OrderMap As Map, Limit As Int) As List 
   
   Dim result As List ': result.Initialize
   
   zCommon.LogT("GetSomeData() start", "")
   
   result = zDBUtilsPenko.ExecuteMemoryFromMaps(zSQLL.SQL1, "data", zCommon.genBlankMap, _
               whereMap, OrderMap, Limit)
   
   zCommon.LogT("GetSomeData() end", "") ' this entry goes to the Log only if the above row is commented!?????? No error or exception messages.
   
   Return result
End Sub

What is bizarre is - I don't get the "end" in LogCat. If I comment the "result = " row, the sub is continued(I get the "end" in LogCat) but the program hangs in a similar way in another Sub.

How is it possible? No error is triggered but they program work flow.

Basically, this is called immediately after inserting in the database, I have a messagebox after it but even it doesn't show up. Very strange! So far, at least there has been an error telling me where to look.

Any ideas?

What I've been thinking, is it possible that a hidden try-catch block(hidden because it is auto-generated by the compiler) catches an event and the remaining code is skipped?

I am asking because the other Sub was hanging similarly until I made it in its own try catch block.

B4X:
   Dim result As List : result.Initialize
   result = GetSomeData(whereMap, orderMap, 1)
   
   zCommon.LogT("GetLastData() result = " & result, "")
   
   Dim m As Map 
   
   Try
      m = result.Get(0) ' before the Try catch, the Sub was dying here and nothing after it was ever executed.
   Catch
   
   End Try
 

Penko

Active Member
Licensed User
Longtime User
The edit is too big for using my previous post.

Sorry for writing the topic but I have been fighting with this for several hours, then decided to start this thread. "Unfortunately", I found the problem 5 minutes after writing here. Erel, maybe you should take a look at the compiler because such errors may happen.

Explanation:

call to the function
B4X:
result = zDBUtilsPenko.ExecuteMemoryFromMaps(zSQLL.SQL1, "data", zCommon.genBlankMap, _
                    whereMap, OrderMap, Limit)

' here we call the genBlankMap() Sub to generate a new initialized map as argument.

definition
B4X:
Sub ExecuteMemoryFromMaps(SQL1 As SQL, Table As String, FieldsList As List, _ ' if we take a look here, we see the argument is "List"
               WhereMap As Map, OrderMap As Map, Limit As Int) As List

B4X:
   Sub genBlankMap() As Map
      
      Dim mm As Map : mm.Initialize
      
      Return mm
   
   End Sub


So, I was passing a "Map" to the third parameter which should have been a "List".

I took the time to write so long in order to notify about the problem. Neither the B4A environment stopped the compilation process, nor the execution on my phone reported any issues, it just stopped the execution of my program making my debugging much harder.

My thread may be ignored at all! A unattended Try-Catch block at the very beginning of the logic flow tricked me and lost my time.
Just one last question - is it normal that my objects which are Class include all other modules as variables?

E.g,
B4X:
Dim data as tData ' tData is just a class encapsulating my Data type. - several private vars and several public subs which return the values.
But along with my "fields", I also get(in the Log) Main=null, activity1=null, contact=null, etc... - > all my activity, code modules. Is this normal?
 
Last edited:
Upvote 0
Top