Android Question Problema with the types and variables.

Discussion in 'Android Questions' started by Glitchs, Aug 28, 2015.

  1. Glitchs

    Glitchs Member Licensed User

    Hello

    I am new with B4A, I am testing the trial version and I'll buy it when the period time will expire. I have a easy problem that I gues it's a unknowledge of VB languaje. It's seems to be ok but when I compile it (GPS library included) the app crash.
    The problem is with the Location. Why?
    ¿Some idea?
    Thanks in advance.


    Code:
    Sub Process_Globals
      
    Type Coche(Name As String, speed As Float, loc As Location )
      
    Public Target As Coche
    End Sub

    Sub Globals
      
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        Target.loc.Initialize
        Target.loc.Latitude=
    41.61208
        Target.loc.longitude=-
    30.20804
    End Sub
     
    Last edited: Aug 28, 2015
  2. DonManfred

    DonManfred Expert Licensed User

  3. Glitchs

    Glitchs Member Licensed User


    Thanks, I have followed that tutorial, and I have wrote a increidible software that detects all the radar cameras and alert me with in my country. The app works ok and I think I understand how the GPS works.
    I would like to have a Type object with the name, speed limit, orientation and ALSO location.

    The problem is the field "loc as location", if I remove it and I left only.....
    Type Coche(Name AsString,........, speed As Float)
    ,the app works ok.

    But then I have to write an independent Variable like "Public PositionRadar as Location"

    I would like to have all the fields togheter at teh same type and not to have to create one variable for the "Name As String, speed As Float, loc As Location" and other separated for Location.

    I hope I can explain myself.

    Why this NOT works....

    Code:
    Sub Process_Globals
      
    Type Radar(Name As String, speed As Float, loc As Location )
    End Sub

    Sub Globals
        
    Public Target As Radar
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        Target.loc.Initialize
        Target.loc.Latitude=
    41.61208
        Target.loc.longitude=-
    30.20804
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub
    And this works:

    Code:
    Sub Process_Globals
      
    Type Radar(Name As String, speed As Float)
    End Sub

    Sub Globals
        
    Public Target As Radar
        
    Public TargetPos As Location
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        TargetPos.Initialize
        TargetPos.Latitude=
    41.61208
        TargetPos.longitude=-
    30.20804
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    Best regards
     
    Last edited: Aug 28, 2015
  4. MaFu

    MaFu Well-Known Member Licensed User

    Because a type must initialized.
    You forgot "Target.Initialize"
     
    Glitchs likes this.
  5. Glitchs

    Glitchs Member Licensed User

    Gracias, that was the problem. My faul was to try initialitate only the location field.
    Thank you very much.
     
  6. MaFu

    MaFu Well-Known Member Licensed User

    You're welcome
     
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