ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

update my scale

Hi,

I would like to update my scale x this way:

if x is between 1 and 9 so increment by 1

if x is between 10 and 90 so increment by 10 each time

if x is between 100 and 900 so increment by 100 each time, and so on

I thought to implement a case structure and test the variable x, but it will over burden my program

Can anyone help me please

Thank you in advance

My best regards

K.Nadia

 

0 Kudos
Message 1 of 5
(3,393 Views)

How would a case structure over burden your application?  If that overburdens your application, you have a lot more issues than this.  A ranged case structure would be the way to handle your scale problem.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(3,389 Views)

I have other tests to do in my code, and what I wrote in my first message is just a part of my code

0 Kudos
Message 3 of 5
(3,381 Views)

I'm not sure what you mean by updating your scale x, but it's pretty simple to go from 'x' to your increment using 10^(floor(log_10(x))

get_increment.png

0 Kudos
Message 4 of 5
(3,356 Views)

Here is a simple function that converts an integer into an "increment" (so 1-9 returns 1, 10-99 returns 10, etc.).  I added a test for 0 and negative numbers, treating them as though they were 1, but you could modify this to better suit your needs.

Increment.png

Bob Schor

0 Kudos
Message 5 of 5
(3,355 Views)