golfinhu Posted January 20, 2010 Share Posted January 20, 2010 Good afternoon, someone could help me? I'm trying to do one function, to eliminate points of values above 1000 eg U$ 1352,00 to U$ 1352,00 could someone help me please? I was thinking of comparing the number of characters, and if larger than 11, use a stringleft and stringright and put them together, but I think there's an easier way to do ... if they can help me, I would greatly appreciate it! thanks Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 20, 2010 Share Posted January 20, 2010 (edited) Func MakeLessThan1000($money) $values = StringRegExp($money, "^U\$ (\d+),(\d\d)$", 1) If @error Then Return $money ; doesn't match for some reason... $number = $values[0] While $number >= 1000 $number -= 1000 WEnd Return "U$ " & $number & "," & $values[1] EndFunc Wrote this up quickly. Haven't tested it. Give it the whole string of "U$ 1352,00" and it will return "U$ 352,00" as long as I did it right. Edited January 20, 2010 by Richard Robertson Link to comment Share on other sites More sharing options...
golfinhu Posted January 20, 2010 Author Share Posted January 20, 2010 (edited) thankyou for your repply, but i'm sorry, wrong in the descriptionright would be:example value:convert thisU$ 1.352,00toU$ 1352,00is basically remove the point, that'sps: I found the edit button in the post! Edited January 20, 2010 by golfinhu Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 20, 2010 Share Posted January 20, 2010 Oh ok. Yeah I can change the code real quick. Lemme know if this one works. Func Fix($money) $values = StringRegExp($money, "^U\$ (\d*).(\d+),(\d\d)$", 1) If @error Then Return $money ; doesn't match for some reason... Return "U$ " & $values[0] & $values[1] & "," & $values[2] EndFunc Link to comment Share on other sites More sharing options...
golfinhu Posted January 20, 2010 Author Share Posted January 20, 2010 Oh ok. Yeah I can change the code real quick. Lemme know if this one works. Func Fix($money) $values = StringRegExp($money, "^U\$ (\d*).(\d+),(\d\d)$", 1) If @error Then Return $money ; doesn't match for some reason... Return "U$ " & $values[0] & $values[1] & "," & $values[2] EndFunc it's work, thankyou so much! Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 20, 2010 Share Posted January 20, 2010 You're welcome. There might be a better way to do it, but if what I did works, then it's fine. Link to comment Share on other sites More sharing options...
darkjohn20 Posted January 20, 2010 Share Posted January 20, 2010 (edited) StringReplace the decimal point with ""? Edited January 20, 2010 by darkjohn20 Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 20, 2010 Share Posted January 20, 2010 StringReplace the decimal point with ""?Now see, that's exactly what I'm talking about. Not once did that cross my mind. Link to comment Share on other sites More sharing options...
darkjohn20 Posted January 20, 2010 Share Posted January 20, 2010 StringRegExp is quite slow compared to StringReplace, and is recommended when possible. Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 20, 2010 Share Posted January 20, 2010 Yeah I know it's slow. I just don't write in AutoIt anymore. I had forgotten the function. 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