Android Question pass parameters with sub

Isac

Active Member
Licensed User
Longtime User
I need to call this sub in another sub




B4X:
Sub JobDone (job As HttpJob)
-------
-----
------
end sub


B4X:
Sub Activity_Create(FirstTime As Boolean)

JobDone (job As HttpJob)   --------------->  job remains in red and I can declare
----
---
---
----
end sub
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
What is it that you are attempting to do exactly?

The normal process is to declare a variable as httpjob, initialise it and set the various properties before making the Get or Post request.
The JobDone sub is then automatically called upon completion of the request.
 
Upvote 0

Isac

Active Member
Licensed User
Longtime User
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
     Dim job as HttpJob
 
End Sub
 
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
 
 
End Sub
 
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    JobDone (job As HttpJob)   --------------> I do not know how to call up a sub with parameters , If I declare Job in global does not compile
 
End Sub
Sub JobDone (job As HttpJob)
    job.Initialize("job",Me)
    job.Download("http://www.google.it")
    If job.Success = False Then
    ProgressDialogShow2("No connection",False)
    Else
    ToastMessageShow("connection ok",True)
    ProgressDialogHide
    End If
End Sub

declaring job as HttpJob global variables from this error:

Parsing code. Error
Error parsing program.
Error description: Parameter name cannot hide global variable name.
Occurred on line: 35
Sub JobDone (job As HttpJob)

Thank you for your help
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
You should think of jobdone as an event. It is fired when the requested job has finished...
so you need first, as Random coder pointed out, to initialize an httputils object, execute your request. Jobdone will then be automatically called upon completion returning the request (job) that fired it
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
move the
B4X:
Dim job as HttpJob
from Process_Globals to Activity_Create
Also call
B4X:
    job.Initialize("job",Me)
    job.Download("http://www.google.it")
inside activity_create and not in JobDone
 
Upvote 0
Top