How convert string to number.
Submitted by Tuesday, 27 September, 2005 - 07:24
on
Hi all,
Currently i'm trying to write macro to convert degrees to decimal form and back and have some problems. Input is string and I need convert that string after splitting into parts to numbers, but macro ends with error complaining that unable to casto sting to integer. parseInt also not working. What's wrong ?
Thanks for answers
Here is code:
void convert_coordinates() { private int Laipsniai; if (textArea.getSelectedText().contains(" ") == true ) { format = 1; Macros.message(view,"Degrees"); } else { format = 0; Macros.message(view,"Decimal degrees"); }; switch (format) { case 1: Elements = textArea.getSelectedText().split(" "); Laipsniai = Elements[0]; Macros.message(view,"Laipsniai: "+Laipsniai); textArea.setSelectedText(Laipsniai); break; case 0: Elements = textArea.getSelectedText().split("[.,]"); textArea.setSelectedText("1:"+Elements[0]+" 2:"+Elements[1]); break; }; } if (textArea.getSelectedText() == null) { Macros.error(view,"No coordinates selected !!!"); } else { convert_coordinates(); };