Android Question Doevents and Sleep(0)

LARRYLGS

New Member
Licensed User
Longtime User
I just upgraded from an older version of B4A. I have a very large IF statement and it would not compile in debug mode, but it does compile in release mode. It gave me many warnings about DoEvents, so I replaced all DoEvents with Sleep(0) and now it does not compile. It gives me the following error:

B4A Version: 7.30
Parsing code. (0.55s)
Compiling code. Error
Error compiling program.
Error description: Cannot return values from this sub.
Error occurred on line: 7446
Return True
Word: return

However it compiles and runs fine using DoEvents. I used Return True to exit from the sub, maybe I should be using something else?
 

LARRYLGS

New Member
Licensed User
Longtime User
I did not post code because project is 13,000 lines. I see that I also have some undeclared variables and a warning: Return type (in Sub signature) should be set explicitly, However I was surprised when it compiles and runs fine with DoEvents but not with Sleep(0). I have used DoEvents in code many times (100+). The first part of code in sub with error is:

Sub Filter_Overlay_Touch(Action As Int, X As Float,Y As Float)
'Msgbox("overlay",Y)
X=X/WS: Y=Y/HS
'Msgbox(X,Y)
Dim Z,ZZ As String
Dim V As Float
Dim PR As String

Select Action
Case Activity.ACTION_DOWN

Z=File.ReadString(File.DirRootExternal,"/JVJ/download/stocktmp")
J=1: 'pointer to first entry in list
H=0: V=0
'CC=Z.Length*.05: '5%
ZZ=""

If X<150 And Y>210 And Y<270 Then
'from price
PriceRangeList.Visible=True
Return True

Else If X<150 And Y>300 And Y<360 Then
'to price
PriceRangeList2.Visible=True
Return True

Else If X<150 And Y>100 And Y<175 Then
'reset
Filter_Overlay.SetBackgroundImage(LoadBitmap(File.DirRootExternal, "/JVJ/images/page/wait.jpg"))
DoEvents
If Instr(SUMMARY.Text&" ","CLEARANCE ITEMS:")>0 Then
Z=File.ReadString(File.DirRootExternal,"/JVJ/download/clear")
tabs(1).Tag="CLEARANCE ITEMS:"
Else
Z=File.ReadString(File.DirRootExternal,"/JVJ/download/stock")
tabs(1).Tag="INVENTORY ITEMS:"
End If

plus many more else if statements.
I wanted to use Return True to exit Sub so code below if statement would not run.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Try this:
B4X:
Else If X<150 And Y>100 And Y<175 Then
'reset
Sleep(0)
Filter_Overlay.SetBackgroundImage(LoadBitmap(File.DirRootExternal, "/JVJ/images/page/wait.jpg"))
If Instr(SUMMARY.Text&" ","CLEARANCE ITEMS:")>0 Then
instead of this:
B4X:
Else If X<150 And Y>100 And Y<175 Then
'reset
Filter_Overlay.SetBackgroundImage(LoadBitmap(File.DirRootExternal, "/JVJ/images/page/wait.jpg"))
DoEvents
If Instr(SUMMARY.Text&" ","CLEARANCE ITEMS:")>0 Then

You should use code tags when post code:
upload_2017-12-19_8-49-2.png
 
Upvote 0
Top