LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicating lines in a save file

Hi I was wondering if anyone could help I have the issue that when I run my program it writes multiple strings into the file where I only want one. I know it has something to do with the loops I'm using but I thought I negated that via a case structure. If anyone could offer advice I would be grateful.

0 Kudos
Message 1 of 6
(1,186 Views)

Oh I forgot additionally I was wondering if you would suggest why there are such vast spaces between my numbers and how I might go about removing them thank you in advanced

0 Kudos
Message 2 of 6
(1,181 Views)

I recommend to go back to the tutorials.

 

  • Your loop spins as fast as the computer allows, repeating the same calculation over and over.
  • Maybe "save data" could be latch action? (Do you know about mechanical action settings?)
  • Your cases differ by a single constant, No need to duplicate all the rest of the code.
  • Have you noticed the coercion dots? They are trying to tell you something.
  • Your case structure after the main loop makes no sense. If you stop the loop, the boolean is guaranteed to be true. The false case can never happen.
Message 3 of 6
(1,163 Views)

Maybe simplify your code? Here's one possibility:

 

(You can easily add your file IO. with a simple case structure connected to a latch action boolean. In the next iteration, use an event structure so it only recalculates when the numeric changes or one of the buttons is pressed).

 

altenbach_0-1617252828750.png

 

0 Kudos
Message 4 of 6
(1,143 Views)

thank you I completely see what you mean about the single constant I had definitely overlooked that. I have been playing with the mechanical actions as obviously I only want the boolean to change for one iteration of the loop per press but as you said the computer seems to be looping multiple times in the time it takes for that one press. I also had not noticed the coercion dots i will have to see if i can identify what they are signaling. thank you.  I will post again when i come across the next issue or if i still struggle to solve this.

0 Kudos
Message 5 of 6
(1,137 Views)

The correct mechanical action is "latch when released". Latch action reverts the button after it is read once by the code.

0 Kudos
Message 6 of 6
(1,117 Views)