Jump to content

Recommended Posts

Posted (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 by concept
Posted

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

Posted

$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.

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...