Android Question pass parameters with sub

Discussion in 'Android Questions' started by Isac, Jan 28, 2015.

  1. Isac

    Isac Active Member Licensed User

    I need to call this sub in another sub




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

    Code:
    Sub Activity_Create(FirstTime As Boolean)

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

    RandomCoder Well-Known Member Licensed 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.
     
    Isac likes this.
  3. Isac

    Isac Active Member Licensed User

    Code:
    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: Jan 29, 2015
  4. Cableguy

    Cableguy Expert Licensed 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
     
    Isac likes this.
  5. DonManfred

    DonManfred Expert Licensed User

    move the
    Code:
    Dim job as HttpJob
    from Process_Globals to Activity_Create
    Also call
    Code:
    job.Initialize("job",Me)
        job.Download(
    "http://www.google.it")
    inside activity_create and not in JobDone
     
    Isac likes this.
  6. Isac

    Isac Active Member Licensed User

    Thank you
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice