concept Posted January 24, 2008 Posted January 24, 2008 (edited) Well, I need to execute something very simple: get a number from file and then manipulate it. I know there must be something like this in the manual and on the forum, I am just unable to find it. Sorry for asking something this trivial. Ok heres what I want: $lopp = wingettext("temp - Notepad") ;Gets a value from file, in this case value is 1000 winactivate("tulem_kiirlaen - Notepad") send($lopp) send("{enter}") $lopp -= 50 winactivate("tulem_kiirlaen - Notepad") send($lopp) the current output is: 1000 -50 But I need the output to be: 1000 950 Thank you! Edit: The source contains one and only one value, no spaces or any other wierd symbols. Edited January 24, 2008 by concept
stampy Posted January 24, 2008 Posted January 24, 2008 well when i look at the code it seems it should work. That is a way to use the operators. I guess you could just try $lopp = $lopp - 50
ginnsu Posted January 24, 2008 Posted January 24, 2008 $lopp is probably a string, and when you perform math operations on a string they interpret the string as 0, so when you do $lopp -= 50 it's doing $lopp = 0 - 50.The solution is to cast $lopp to a number first, just add $lopp = Number($lopp) or even $lopp = Int($lopp) before you do any math on it.
concept Posted January 24, 2008 Author Posted January 24, 2008 Oh yes, some parsing was exactly what I needed thank you. Altho I have to point out that it is illogical that a string variable is given a value 0 when encountering wrong format, synthax really should output some kind of a notice i.e. "Wrong format, got String expected int". This will certanly take some getting used to. thanks again
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