constantly update range of values (mouse x axis)

R_Gol's icon

I would like to make a system that constantly update the two extreme points of input data (point max and point min)
Assuming I'm starting in point 200. the system should update both min and max point to 200. I then move the mouse to the right and now the mouse is at point 203. The max point should be updated to 205 while the min point should stay at 200. I continue to move the mouse and I'm at 197. The min point should be updated to 197 while the max point should be stay at 205. Any tips how can I do the following?


--------

another question I have is how can I output the index of an element in a list if the input data is equal to any of the element within that list

I have a list with the following numbers: 5.5 7.7 3.33 11.11

if input data is equal to one of those numbers then it should output the index of that number in that list.
so if the number I check is 3.33 the output should be 2 (3.33 is at index 2 of that list)

Max Patch
Copy patch and select New From Clipboard in Max.


thanks!

11OLSEN's icon

This should answer both questions:

Max Patch
Copy patch and select New From Clipboard in Max.

R_Gol's icon

Thanks!

R_Gol's icon

I have an issue when try to output the index when the input data is constantly changes:

Sometimes it indeed output the index of the element is comparing but sometime not. What makes this unstable?

Max Patch
Copy patch and select New From Clipboard in Max.

11OLSEN's icon

you have 2 problems here:

1. if you move the mouse fast enough, it will skip numbers. Max can't update events faster than 1ms.
In this thread you'll find abtractions to create a ramp without skipping numbers.

2. Your calculation of 777 / 100. will never be 7.77. Even if the result is displayed as 7.77 it is actually 7.769999980926513671875 and therefore doesn't match. It is a mystery for myself why 7.77 in a message box does not follow this rule. In a another thread @source audio discovered that only [sprintf] can help to overcome this problem.

Max Patch
Copy patch and select New From Clipboard in Max.


Your example changed like this should now match all numbers:

Max Patch
Copy patch and select New From Clipboard in Max.


R_Gol's icon

Much clearer now! thanks for explaining