I need to have an icon show positive and negative angles, But my display can not show the negative numbers. Example: ( / -15 degrees ) ( \ 15 degrees ) but the (-) symbol cannot show. Also, I need to be able to add or subtract to manually input my angles. --> would add 1 degree while <-- would subtract 1 degree from 99 -> 0 <- 99. I have use LVAR1 + 1 to add and LVAR1 - 1 to subtract but when I subtract 0 -1 I get -1 how can I show this as 1 and still be able to say -1 - -1= 2 and so forth. I have tried math.abs but that just returns 0 - 1 = 1. also tired to slice the (-) but I don’t this works as I thought it would. I realize this is a little confusing but any help would be grateful!!

Please share an example file showing the problem. It’s hard to tell why it’s working when we can’t see it not working. Your description is hard to follow and doesn’t demonstrate how you implemented it when it might be an implementation problem.

Here is a quick sample… it is supposed to show light facing down @ 0 and Light facing left when numbers are negative and right when positive. But I can not have negative numbers.

example.rp (103.5 KB)

Can you describe the problem in more detail? Seems to be fine to me, unless I’m misunderstanding something…

Do you mean you don’t want negative numbers? Math.abs() should do the trick. However, when you say:

```
-1 - -1= 2
```

that is incorrect. `-1 - -1 = -1 + 1 = 0`

. However: `Math.abs(-1) - -1 = 2`

, though. This seems to be an arithmetic problem, as Axure seems to be working fine. I’m having a hard time understanding what outcome you expect.

I can not have a negative number showing. For this icon I need to always show a positive number. If I use Math.abs() I can not do the math to have basically -2 or -3 but only show 2 or 3. I know this is really confusing… but think of it like a number line the further I go left the more negative I get, but, I can only show postive numbers no matter which side of the number line I’m on. I hope this helps explain this a little more and thank you for trying to help out

Ok, I understand now. I thought you were trying to show negative numbers and it isn’t working.

The reason why you’re having trouble is you have coupled state and display. You’re using the text on the `number`

widget to both show the number (display) as well as track its value (state). The problem is, you don’t want to show and track the same number. You want to track the number as negative so your math works correctly, but you want to show the number as positive always. This means you should track and show different numbers.

You’re currently using a local variable set to the text of the `number`

widget to do your math. This breaks when you then change the display, as now your calculations are using the wrong number. Instead use a Global Variable to track the number. Now you can use the number one way for your calculations (unaltered) and use it differently when you show it (alter it to make it positive).

Here’s a working example (note: you don’t have any case for when the number is 0, you’ll have to add that in if you want it).

example-fix.rp (103.9 KB)

We use the `Degrees`

global variable to track the state, what the number currently is. This is used for all the conditions and cases. Finally we use the absolute value of this variable for the display (`[[Math.abs(Degrees)]]`

).

Awesome!!! thank you for your help, I have been searching for this for the last week and could not find anything. Thank you agian for you help and patience.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.