string ?

derez

Expert
Licensed User
Longtime User
I got an error on this and I don't inderstand it:

B4X:
direction = (tc /DtoR + 540)Mod(360)

all variables here are defined as numbers, DToR = cPI/180,
tc = ACos((Sin(s_lat)-Sin(f_lat)*Cos(d))/(Sin(d)*Cos(f_lat)))
:confused:

Edit: - found it, direction was already declared as global, but still, the message text is not directing to the problem.
 

Attachments

  • gpsd.jpg
    gpsd.jpg
    25.3 KB · Views: 206
Last edited:

agraham

Expert
Licensed User
Longtime User
I can't reproduce that error from the information given as it shouldn't matter that direction was already a global and you should get an error if you try to redeclare it as a local. It should also work whether direction was declared as a default, String or Number type. So I'm wondering what the real reason for that error is :confused:
 

derez

Expert
Licensed User
Longtime User
You are right, the problem was that I had two variables named direction , one was global and the other - local.

The compiler solved some mishaps that I had with the other variable.

solved by changing the name.
 

agraham

Expert
Licensed User
Longtime User
Sory, I don't think I have made myself clear. I would be interested to see if you could reproduce that error and post the code as I don't think it should be possible, using regular variables, for that error to have occurred at compile time. If you locally redeclared a global variable you should have got a redeclaration error at compile time and if you were assigning a number to a string variable Basic4ppc should have emitted the code to convert it and you wouldn't get an error until runtime if it were not possible.
 

derez

Expert
Licensed User
Longtime User
I can reproduce the error:
direction is global with value ( not defined as Number)

In a sub, direction is defined (again), but as Number.
when assigning direction the error appears in compilation (I don't know what happens when running from IDE because this program can run on device only).

I checked in a simple program - when running the IDE I get error about the re-dclaration of the variable. Compilation brings up the implicit string etc.
 
Top