Bug? Code execution skips my IFs !!!

Sepehr_b

Member
Hi,
In my code, I came into that it skips (ignores) my IF conditions and executes the next line after that. I tried many parts and finally could make the IF condition visible to the compiler by adding a dummy function before IF conditions. see the code bellow :

[CODE lang="b4x" title="ambigious IF blockes" highlight="6,12,22"]Private Sub etBarcode_EnterPressed
Try
If etBarcode.Text.Length > 0 Then
Dim OkYet As Boolean = True
' check the format (lenght and starting characters)
Fn.DoNothing
If OkYet = True And (etBarcode.Text.Length <> 13 Or etBarcode.Text.CharAt(0) <> "3") Then
Fn.ErrorTone("شناسه رهگیری باید بک عبارت عددی 13 رقمی باشد و با 3 شروع میشود")
OkYet = False
End If
' check if it is in current list and repeating barcode
Fn.DoNothing
If OkYet = True Then
Dim FDSID As Int = Fn.IfNull(B4XPages.MainPage.db.ExecQuerySingleResult($"Select FDSID FROM FactorDetailSerials WHERE FId = ${FId} And SmtTC = '${etBarcode.Text}'"$),0)
If FDSID > 0 Then
clv_ItemClick (lstFDSID.IndexOf(FDSID) ,FDSID)
clv.ScrollToItem(lstFDSID.IndexOf(FDSID))
Fn.okTone($"شناسه رهگیری ${etBarcode.Text} قبلا در این فاکتور ثبت شده است و تکراری است!"$)
OkYet = False
End If
End If
Fn.DoNothing
If OkYet = True Then ' get the TC info from server or create it and get the created info
Dim NeedUpload As Boolean = False
' first, query the PartSerial info from server
Dim mapPartSerial As Map
mapPartSerial.Initialize
...
...[/CODE]

and the doNothing is :
[CODE lang="b4x" title="DoNothing"]Public Sub DoNothing()
' this routine do nothing
' this is used in some if - end ifs
End Sub
[/CODE]

if I comment the fn.DoNothing calls, the the following IF condition lines are agnored!

I am using B4A ver 12.80
I wonder why!?!?!
 
Run the project step-by-step, pressing F8 (in debug mode).
I did it and by running step-by-step, I found it out!
I saw that it skips my IFs! and when I added the dummy function, It didn't.
I was searching for some compiler optimization setting, (shortening the if conditions in compiler) but I didn't find any
 
Hi,
In my code, I came into that it skips (ignores) my IF conditions and executes the next line after that. I tried many parts and finally could make the IF condition visible to the compiler by adding a dummy function before IF conditions. see the code bellow :

[CODE lang="b4x" title="ambigious IF blockes" highlight="6,12,22"]Private Sub etBarcode_EnterPressed
Try
If etBarcode.Text.Length > 0 Then
Dim OkYet As Boolean = True
' check the format (lenght and starting characters)
Fn.DoNothing
If OkYet = True And (etBarcode.Text.Length <> 13 Or etBarcode.Text.CharAt(0) <> "3") Then
Fn.ErrorTone("شناسه رهگیری باید بک عبارت عددی 13 رقمی باشد و با 3 شروع میشود")
OkYet = False
End If
' check if it is in current list and repeating barcode
Fn.DoNothing
If OkYet = True Then
Dim FDSID As Int = Fn.IfNull(B4XPages.MainPage.db.ExecQuerySingleResult($"Select FDSID FROM FactorDetailSerials WHERE FId = ${FId} And SmtTC = '${etBarcode.Text}'"$),0)
If FDSID > 0 Then
clv_ItemClick (lstFDSID.IndexOf(FDSID) ,FDSID)
clv.ScrollToItem(lstFDSID.IndexOf(FDSID))
Fn.okTone($"شناسه رهگیری ${etBarcode.Text} قبلا در این فاکتور ثبت شده است و تکراری است!"$)
OkYet = False
End If
End If
Fn.DoNothing
If OkYet = True Then ' get the TC info from server or create it and get the created info
Dim NeedUpload As Boolean = False
' first, query the PartSerial info from server
Dim mapPartSerial As Map
mapPartSerial.Initialize
...
...[/CODE]

and the doNothing is :
[CODE lang="b4x" title="DoNothing"]Public Sub DoNothing()
' this routine do nothing
' this is used in some if - end ifs
End Sub
[/CODE]

if I comment the fn.DoNothing calls, the the following IF condition lines are agnored!

I am using B4A ver 12.80
I wonder why!?!?!
I noticed that if the If condition produces a False then that code line may (or never will?) not be highlighted when running in Debug mode.
It won't be ignored though in Release mode.

RBS
 
Back
Top