LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

clear 1d array with boolean?



@unknown00 wrote:
i got it. had to create another loop for the boolean button inside the loops instead of out and used the string constant and seems to work fine atm 🙂

That sounds way too convoluted. Can you show us your final code?
0 Kudos
Message 11 of 22
(1,094 Views)
look at first post for original and this is editted...basically just added another case structure in the loops

0 Kudos
Message 12 of 22
(1,088 Views)
actually i lied...doesn't work 😞 sigh

it actually doesn't do anything i wanted it to in original post...what am i thinking

Message Edited by unknown00 on 06-25-2007 02:17 PM

0 Kudos
Message 13 of 22
(1,080 Views)
It would really help to see the real code, because I see many problems:
  • Your shift register is not initialized, so you might retain stale data from previous runs.
  • the [equal ""] is not needed, just wire the string directly to the case structure and make one case "".
  • The built array node probably belongs inside the TRUE case of the inner case.
  • Why are you writing to a terminal AND to a local variable of it at the same time? The local variable can be deleted without change in outcome. (Run Numbers)
  • The "close" subVI will run at a random time relative to the FOR loops. Is that intentional?
  • What output do you actually want? Since the loop runs so fast that is is virtually impossible to time the user interactions with presses of "append to array", most likely all you get is either an array with all empty strings removed or an array with a the last element as the only element. Why do you even run the two loops pumping nothing but hot air if append is FALSE? I think the inner case structure belongs outside the two loops.
0 Kudos
Message 14 of 22
(1,066 Views)
figured out loops at to convert 2d array to 1d but that doesn't help much. here is attached code. basically when true append to array when false create new array (delete all from old append new) can't get it to work
0 Kudos
Message 15 of 22
(1,050 Views)


@unknown00 wrote:
figured out loops at to convert 2d array to 1d but that doesn't help much. here is attached code. basically when true append to array when false create new array (delete all from old append new) can't get it to work

OK, we need a better description!
 
You seem to try to convert a 2D array of strings to a 1D array of strings with all blank elements missing. I assume that if "append to array" is TRUE, you just want the output as described here.
 
With the current code, you also retain data from previous runs inside the shift register. Do you want to retain these or do you want to start with a new array whenever the program runs?
 
What I don't understand is what should happen if the button is FALSE. What should the output be? (e.g. empty array?). What is your definition of OLD and NEW above. Is old from a previous run???
 
Why is the button inside the innermost loop. Does it make sense to be able to change its state during execution of the FOR loops? (Most likely, the loop run is so fast that you won't be able to throw the switch halfway during execution.
 
How do you run the program. Is it the toplevel (since you don't have any connectors defined, it seems to be).
0 Kudos
Message 16 of 22
(1,045 Views)
yes if it's true i just want it to output but also append to the previous runs

With the current code, you also retain data from previous runs inside the shift register. Do you want to retain these or do you want to start with a new array whenever the program runs?
i think that's my main problem. if i could get it so when button is true it keeps previous run and when button is false it doesn't keep it and starts with a new array then i think my problems will be solved! ***

when button is false it should display ONLY data from inputted excel sheet WITHOUT previous runs. when is true it should display data from inputting excel sheet WITH previous runs

i just put the button in innermost loop because i thought it'd be most logical there...it doesn't have to be

yes this is toplevel
0 Kudos
Message 17 of 22
(1,040 Views)
See if this works for you (LV 8.0).
 
 
0 Kudos
Message 18 of 22
(1,031 Views)
works great! i have a question. when you personally ran it, did you test it with an actual excel sheet? if yes, did you have to stop the program everytime when you wanted to add another sheet and then click run? cause when i run it i have to stop it everytime i want to add another excel sheet to it Smiley Sad
0 Kudos
Message 19 of 22
(1,026 Views)

No, I did not test the excel part and I don't really want to. I don't understand why you say you need to stop the program. Since it only runs once, it stops automatically after each run. (Don't use the continuous run button!!!)

To test, I just copied the loops into a fresh VI and used a 2D array of strings as input (size 2x2, one element with a blank string).

Make sure you undestand my code, these are some very basic designs. (It might be better to use a WHILE loop for the outer loop with the stop condition hardwired to stop).

Message Edited by altenbach on 06-25-2007 02:38 PM

0 Kudos
Message 20 of 22
(1,022 Views)