Android Question Problema with the types and variables.

Glitchs

Member
Licensed User
Longtime 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.


B4X:
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:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Glitchs

Member
Licensed User
Longtime 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....

B4X:
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:

B4X:
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:
Upvote 0
Top