Page 1 of 1

Negitive Number to Positve Value

PostPosted: Sun May 13, 2012 10:29 pm
by LauraMarie
I am trying to figure out how to convert a negative number to a positive using the Math object. Does anyone know how this can be accomplished?

PostPosted: Sun May 13, 2012 10:30 pm
by HPW
Multiply with -1 ?

PostPosted: Sun May 13, 2012 11:06 pm
by LauraMarie
Let me explain what I mean.

As I move my image up and off screen my Y position of the picture object becomes let's say -97. But what I want need is store that value in a variable as a positive number 97. This must be a part of my script which is triggered by a trackbar object that is always changing as the user moves it.

So I need a way using the math object to accomplish this.
Not sure what you mean by "multiply -1" ?

PostPosted: Sun May 13, 2012 11:49 pm
by Odd
You may use NeoBook's build-in abs function to retrieve the positive number.

PostPosted: Mon May 14, 2012 6:20 am
by LauraMarie
Thank you Odd.

What is the syntax for using the abs function?
I have tried using it several ways but get an error as result.

PostPosted: Mon May 14, 2012 6:27 am
by HPW
Code: Select all
Math "Abs(-97)" "0" "[Result]"
Alertbox "Result Abs" "[Result]"

Math "-97 * -1" "0" "[Result]"
Alertbox "Result -1" "[Result]"

PostPosted: Mon May 14, 2012 7:22 am
by LauraMarie
Thanks for the clarification.