Ultima2 Posted December 13, 2008 Share Posted December 13, 2008 (edited) $number = 2.3 $number1 = 1.5 $ok = ""&$number&", "&$number1&"j" How do I extract $number and $number1 from the string and set them separately to float point numbers again? I tried the help file but couldnt find anything that could help me Edited December 13, 2008 by Ultima2 Link to comment Share on other sites More sharing options...
FireFox Posted December 13, 2008 Share Posted December 13, 2008 $number = 2.3 $number1 = 1.5 $ok = ""&$number&", "&$number1&"j" How do I extract $number and $number1 from the string and set it to a float point number again? I tried the help file but couldnt find anything that could help meHi, For extract it you can use string functions : StringSplit StringLeft StringRight StringTrimLeft StringTrimRight StringReplace ........ Link to comment Share on other sites More sharing options...
Ultima2 Posted December 13, 2008 Author Share Posted December 13, 2008 Could you post an example please, that doesn't really help me because im still a newbie D: Link to comment Share on other sites More sharing options...
FireFox Posted December 13, 2008 Share Posted December 13, 2008 Could you post an example please, that doesn't really help me because im still a newbie D:$String="Number 1.5 and Number 2" $Number1=StringLeft(StringTrimLeft($String,7),3) $Number2=StringRight($String,1) Msgbox(64,"",$Number1&" and "&$Number2) You can check this functions on autoit helpfile with F1 key in SciTE Link to comment Share on other sites More sharing options...
Ultima2 Posted December 13, 2008 Author Share Posted December 13, 2008 (edited) Ok thank you very much, but what if you dont know the exact digit of the number, like log(3). Like $x = log(3) $z = log(2) $ok = ""&$x&", "&$z&"" How would you extract the entire value of $x and $z from the string? Thanks Edited December 13, 2008 by Ultima2 Link to comment Share on other sites More sharing options...
FireFox Posted December 13, 2008 Share Posted December 13, 2008 Ok thank you very much, but what if you dont know the exact digit of the number, like log(3). Like $x = log(3) $z = log(2) $ok = ""&$x&", "&$z&"" How would you extract the entire value of $x and $z from the string? Thanks Do you want to search all numbers in a log ? (1-9) Link to comment Share on other sites More sharing options...
Pain Posted December 13, 2008 Share Posted December 13, 2008 Try this #include <Array.au3> $x = log(3) $z = log(2) $ok = ""&$x&", "&$z&"" ;~ $number = 2.3 ;~ $number1 = 1.5 ;~ $ok = ""&$number&", "&$number1&"j" ConsoleWrite($ok) $new = StringRegExpReplace($ok,"[^0-9.\s]","") $array = StringSplit($new, " ") _ArrayDisplay($array) Link to comment Share on other sites More sharing options...
Ultima2 Posted December 13, 2008 Author Share Posted December 13, 2008 No I just want to know how to extract a number from a string. How do I extract a number from a string if I dont know the exact length of the number. like sqrt(5). Link to comment Share on other sites More sharing options...
FireFox Posted December 13, 2008 Share Posted December 13, 2008 No I just want to know how to extract a number from a string. How do I extract a number from a string if I dont know the exact length of the number. like sqrt(5).if you don't length of the number you have to search it... look at StringRegExp , Stringinstr Link to comment Share on other sites More sharing options...
Ultima2 Posted December 13, 2008 Author Share Posted December 13, 2008 I cant understand the help file. They're like written for people with 180+ IQ. Like for the code $x = log(3) $z = log(2) $ok = ""&$x&", "&$z&"" I have a string "$x, $z". How do I extract $x and $z from the string. I cant use the method you showed me earlier because it only works if I know the exact length of log(3) and log(2). Link to comment Share on other sites More sharing options...
Pain Posted December 13, 2008 Share Posted December 13, 2008 (edited) $number = 2.3 $number1 = 1.5 $ok = ""&$number&", "&$number1&"j" ConsoleWrite($ok & @CR) $new = StringRegExpReplace($ok,"[^0-9.\s]","") $array = StringSplit($new, " ") ConsoleWrite($array[1] & " " & $array[2] & @CR) $x = log(3) $z = log(2) $ok = ""&$x&", "&$z&"" ConsoleWrite($ok & @CR) $new = StringRegExpReplace($ok,"[^0-9.\s]","") $array = StringSplit($new, " ") ConsoleWrite("x=" & $array[1] & " z=" & $array[2] & @CR) If this isn't what you asked for please explain how you mean. Edited December 13, 2008 by Pain Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 13, 2008 Share Posted December 13, 2008 $x = 3.14 $z = 2.6243563 $ok = $x & "," & $z $ss = StringSplit($ok, ",") ; $ss is [2, "3.14", "2.6243563"] $newx = Number($ss[1]) $newy = Number($ss[2]) Link to comment Share on other sites More sharing options...
Ultima2 Posted December 13, 2008 Author Share Posted December 13, 2008 Thank you. I'll try to read the help file again. The help file is like written in another language, I only understand like 2% of it Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now