Jump to content
Sign in to follow this  
concept

Something very simple

Recommended Posts

concept

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

Share this post


Link to post
Share on other sites
stampy

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

Share this post


Link to post
Share on other sites
ginnsu

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

Share this post


Link to post
Share on other sites
stampy

I didn't even see that. Good point.

Share this post


Link to post
Share on other sites
concept

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

Share this post


Link to post
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
Sign in to follow this  

×