Jump to content

Something very simple


concept
 Share

Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...