B4J Question Abmatetial problem with resumable sub

mauriegio

Member
Licensed User
Longtime User
Good Morning,

j have a problem with abmaterial autentication, wiht resumbale sub

B4X:
public Sub CheckLogin(login As String, password As String) As Boolean
    ' check if the login is valid and return true if it does
    Dim rs As ResumableSub = LeggiConfig(login, password)
    Wait For (rs) Complete (Result As Boolean)
    Return Result
End Sub
 
Last edited:

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
A resumable sub cant return a boolean type, it has to be a resumable object.

Beside that. Without the error or more information is hard to understand whats missing.
 
Upvote 0

mauriegio

Member
Licensed User
Longtime User
Sorry for little information , but the error is in the routine
public Sub CheckLogin(login As String, password As String) As Boolean
Error
Main - 72: The return type from Resumable routines must be ResumableSub (or nothing).

but i can't change this routine because is part of ABMaterial ...
thanks
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
The error is exactly what i suggested, it doesn't allow a resumable sub to return a boolean,

Most of abmaterial methods are touchable, you should try to modify it or show us where you are using it so we can suggest alternatives.

Abmaterial came first than resumablesubs but the way.
 
Upvote 0

mauriegio

Member
Licensed User
Longtime User
B4X:
public Sub CheckLogin(login As String, password As String) As Boolean
    ' check if the login is valid and return true if it does
    Dim rs As ResumableSub = LeggiConfig(login, password)
    wait For (rs) Complete (Result As Int)
    If Result = 1 Then
       Return True
    Else
       Return False
    End If
End Sub

i changed to int but the same problem
on line CheckLogin ( Main - 72: The return type from Resumable routines must be ResumableSub (or nothing). )

what i can do ?

thanks
 
Upvote 0

mauriegio

Member
Licensed User
Longtime User
Hello,
i need to call a API on a remote server , for autentication by login and password,
but i need to wait the finish he call ...
LeggiConfig do that !!!

How i can resolve this problem ?

thanks
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
B4X:
public Sub CheckLogin(login As String, password As String) As Boolean
    ' check if the login is valid and return true if it does
    Dim rs As ResumableSub = LeggiConfig(login, password)
    wait For (rs) Complete (Result As object)
    If Result = 1 Then
       Return True
    Else
       Return False
    End If
End Sub
And you don't need to convert int to Boolean, if x=True or if x=1 is exactly the same. 1 is true, 0 is false
 
Upvote 0

mauriegio

Member
Licensed User
Longtime User
Immagine 2021-07-28 121459.png

The return type from Resumable routines must be ResumableSub (or nothing).
any idea ?
thanks
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
It has nothing to do with ABMaterial (which is a library), but is normal B4J code. You can change those parts to whatever you need.

You can probably just skip this method all together and just call your LeggiConfig method directly where you are calling CheckLogin:
B4X:
' something like
'if CheckLogin(login,password) then
' replace by
Dim rs As ResumableSub = LeggiConfig(login, password)
wait For (rs) Complete (Result As object)
If Result = 1 Then
    ' do whatever you need to do if the login is ok
Else
    ' do whever you want to do if the login is not ok
End If

Alwaysbusy
 
Upvote 0
Top