Hi, I have recently been alerted by some masters of these forums that I am doing something wrong with calls to some "Sub" that return nothing, they do not need to be "ResumableSub".
I am in the habit of always using "ResumableSub" even if it should not return any value. I do this to make sure that each "Sub" is executed before the next "Sub" is executed.
I paste a piece of example code so you can understand what I mean.
Why is it wrong, why shouldn't it be done this way?
I am in the habit of always using "ResumableSub" even if it should not return any value. I do this to make sure that each "Sub" is executed before the next "Sub" is executed.
I paste a piece of example code so you can understand what I mean.
Why is it wrong, why shouldn't it be done this way?
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("ftpv320x480")
Wait For (CrearDirectorios) complete (oRes As Object)
Wait For (setEstetica) complete (oRes As Object)
Wait For (LimpiarDB) complete (bRes As Boolean)
if bRes Then
' ...
End If
Wait For (ShowTitulo) complete (oRes As Object)
End Sub
Sub CrearDirectorios As ResumableSub
Dim rp As RuntimePermissions
globales.cDBruta = rp.GetSafeDirDefaultExternal("")
globales.cDirFotos = rp.GetSafeDirDefaultExternal(globales.cNameDirFotos)
'
Return Null
End Sub
Sub setEstetica As ResumableSub
pnCabecera.Color = globales.iColorNaranja
pnFondo.Color = globales.iColorCelesteOscuro
pnBotones.Color = globales.iColorCelesteOscuro
pnBotones.Visible=True
'
Return Null
End Sub
Sub LimpiarDB As ResumableSub
Dim cSq1 As String = $"delete from tbNotasLineasCombinados"$
Dim cSq2 As String = $"delete from tbNotasLineasComponentes"$
Dim cSq3 As String = $"delete from tbAgrupamientoDatosVenta"$
Dim acSq() As String = Array As String(cSq1,cSq2,cSq3)
'
For i=0 To acSq.Length -1
globales.DBconex.AddNonQueryToBatch( acSq(i), Null )
Next
Dim SenderFilter As Object = globales.DBconex.ExecNonQueryBatch("SQL")
Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
'
Return Success
End Sub
Sub ShowTitulo As ResumableSub
lbEmpresa.Text = NumberFormat(globales.cCodigoEmpresa,2,0)
lbVendedor.Text = NumberFormat(globales.cCodigoVendedor,3,0)
'
Return Null
End Sub