LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Quick While Loop Problem

A few more tips:

 

 

  • The two "delete from array" right after reading the file can be replaced by a "single array subset".
  • The generation of the output file name is also overly complicated. Simply use build path as shown here. (You should never do string operations on paths (only on file names!). Paths are OS independent, while paths manipulated as strings will break on another OS because the delimiters are different.

0 Kudos
Message 11 of 15
(904 Views)

 


altenbach wrote:
  • The two "delete from array" right after reading the file can be replaced by a "single array subset".

of course I meant:  ... single "array subset".

 

0 Kudos
Message 12 of 15
(897 Views)

 


@AlexP1 wrote:

oops, forgot to attach the VI


 

A few more comments to get you going:

 

 

  • OK, the event structure goes inside the FOR loop and not vice versa! The OK button should be latch action and placed inside the event.
  • The way you rename the file is extremely dangerous (same as my workaround). For example if you would accidentally select a file that does not end in ".csv" (e.g. "TheOnlyCopyOfMyFinalThesis.doc" ;)), the generated filename would be identical to the original file name and the code would potentially overwrite your important document. A good option would be to use the file dialog with "*.csv" as pattern so you can only select correct files. Then you also need to make the replace operation case insensitive. Newer LabVIEW versions also have a tool to split filename and extension.

 

 

0 Kudos
Message 13 of 15
(879 Views)

Ok, I think I'm really close.  I've noticed that the event structure keeps my while loop from running, so the system hangs even if I hit the stop button because the boolean value never actually changes. 

 

I looked at these threads and it seems like I have a similar problem: 

Thread1

Thread2

 

So I added another event for the while loop cancel button that simply wires a True value to the while loop condition.  This works, but I get an error 1045:  A Null Refnum is passed to the close reference function.  How do I make a refnum constant?  Not really sure what that is.  Or should I handle this case a different way? 

0 Kudos
Message 14 of 15
(866 Views)

@AlexP1 wrote:

Ok, I think I'm really close.  I've noticed that the event structure keeps my while loop from running, so the system hangs even if I hit the stop button because the boolean value never actually changes. 

 

I don't understand what you are saying here. What boolean are you talking about?

 

So I added another event for the while loop cancel button that simply wires a True value to the while loop condition.  This works, but I get an error 1045:  A Null Refnum is passed to the close reference function.  How do I make a refnum constant?  Not really sure what that is.  Or should I handle this case a different way? 

 

You need to make sure your refnum has the wire running through all events.  You should disable the "Use Default if Unwired" option on that tunnel.  That way if you had a new case, your code won't break until you go and put your wire through.  LIkewise for your orange wires coming out of the loop and going to the spreadsheet file.  Since the only way to stop the loop is with the stop button, and that case doesn't have the wires going through, you are going to always have default data of zero coming out of those tunnels going to the Spreadsheet File function.


 

0 Kudos
Message 15 of 15
(861 Views)