Hello,
I've stored my current location in the "location" string. It is currently something like "40.245,29.085".
I need to change the longtitude and langtitude values from the location string.
I've tried to get the comma location by using indexOf like this but it returns 23. It should be 9.
X=indexOf(location, ",");
Then I've tried to split it,
X=split(location, ",")[0];
But it returns "Location[fused 40***"
Then I've tried
X=left(location, 9);
But it also returns "Location[fused 40***"
Most probably I've missed something.
How can I performs split, indexOf, left operations on string?
Regards.
indexOf returns incorrect result
Moderator: Martin
Re: indexOf returns incorrect result
Use a debug dialog to check the variable "location", click on it and select "Show value in text editor". You will see that the value of the variable is in a special format. You have to format it first.
Now you can use indexOf on "loc" to get the position of the comma or split to separate lat and lng.
Code: Select all
loc = "{location,locationformat,decimal}";
Re: indexOf returns incorrect result
To add on, you can then split the {loc} to get the lat and long.
lat will be 40.245 and lon will be 29.085. You can do aritmethic operation on it and then recreate back the location using newLocation(lat, lon)
Code: Select all
location = newLocation(40.245, 29.085);
loc = "{location,locationformat,decimal}";
lat = split(loc, ",")[0];
lon = split(loc, ",")[1];
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.