LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with array

Solved!
Go to solution

Hello!

I need to identify all numbers divisible by 7 up to a number M, provided as input information.

In the false case it is empty, but when I let it run I also get 0 for each run of for, how do I solve this?

zzz.png

0 Kudos
Message 1 of 7
(200 Views)

Because your output tunnel is set to use default if unwired, which is zero.

 

Instead of a case structure, use a conditional output tunnel.

There should be nothing orange, right? the number of iterations is an integer. You cannot have 3.5 iterations, for example.

There is also no need to multiply by 7 if you would wire [i] to the output tunnel directly, right?

 

See if this can give you some ideas....

 

altenbach_0-1712439892364.png

 

Message 2 of 7
(192 Views)

hmm

its not working -_-

For M=20

In result, with my program: 0 , 0 ,0 ,0 ,0 ,0 7,0 ,0 ,0 ,0  , 0 ,0 ,14

But i need: 7 , 14 

yyy.png

0 Kudos
Message 3 of 7
(153 Views)

Obviously, you made a glaring mistake, but we cannot tell what's wrong because you failed to attach your VI!

 

It seems you don't understand how to do a conditional tunnel and did something, e.g. a plain indexing tunnel. Did you even look at my link?

 

Please attach your Vi (make sure to "save for previous", 2020 or below, first).

 

My code works just fine:

 

altenbach_0-1712501209449.png

 

0 Kudos
Message 4 of 7
(132 Views)

Now the Rube-Goldberg way:

Check the octal cross sum…😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 7
(112 Views)
Solution
Accepted by topic author MSF99

Seven.png

0 Kudos
Message 6 of 7
(89 Views)

Well, if you want to go "orange is the new blue", here's another possibility:

 

altenbach_0-1712586053714.png

 

 


@jjohn1 wrote:

Seven.png


Not sure why you kept the orange, but this seems simpler....

 

altenbach_1-1712586273617.png

 

 

Of course the original problem was to "I need to identify all numbers divisible by 7 up to a number M, provided as input information.", which is just a programming exercise that should generate all possible candidates, then identifies the ones divisible by 7. Thus my original solution is probably most appropriate (Or Gerd's detour via pink :D).

0 Kudos
Message 7 of 7
(74 Views)