Source language: Translate to:

Negitive Number to Positve Value

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Negitive Number to Positve Value

Postby LauraMarie » Sun May 13, 2012 10:29 pm

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?
User avatar
LauraMarie
 
Posts: 58
Joined: Sat May 05, 2012 8:02 am

Postby HPW » Sun May 13, 2012 10:30 pm

Multiply with -1 ?
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby LauraMarie » Sun May 13, 2012 11:06 pm

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" ?
User avatar
LauraMarie
 
Posts: 58
Joined: Sat May 05, 2012 8:02 am

Postby Odd » Sun May 13, 2012 11:49 pm

You may use NeoBook's build-in abs function to retrieve the positive number.
User avatar
Odd
 
Posts: 81
Joined: Sat Apr 02, 2005 3:34 am
Location: Norway

Postby LauraMarie » Mon May 14, 2012 6:20 am

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.
User avatar
LauraMarie
 
Posts: 58
Joined: Sat May 05, 2012 8:02 am

Postby HPW » Mon May 14, 2012 6:27 am

Code: Select all
Math "Abs(-97)" "0" "[Result]"
Alertbox "Result Abs" "[Result]"

Math "-97 * -1" "0" "[Result]"
Alertbox "Result -1" "[Result]"
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby LauraMarie » Mon May 14, 2012 7:22 am

Thanks for the clarification.
User avatar
LauraMarie
 
Posts: 58
Joined: Sat May 05, 2012 8:02 am


Return to NeoBook Action Commands

Who is online

Users browsing this forum: Bing [Bot] and 2 guests