From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write to spreadsheet occurs twice

Hi Folks.

 

I the VI attached I am using write to spreadsheet to write to a file. However 2 rows are created every time I hit the generate button. Why is this? Is there a setting I am missing and why does it default to two? Anyone know how to rectify this?

 

Thanks,

 

Mark.

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

As a first step you should change the mechanical action of your generate button to "latch when released" action (currently latch until released).

Try to find a way that the program does not use 100% CPU while it is not doing anything. Desing the code as a state machine instead of a "sequence worm". Take some LabVIEW courses and tutorials. What's the point of all these delays in the sequence?

Message 2 of 6
(2,803 Views)

Thanks. The latch action sorted it. I will change it to event driven. Just getting things working for the moment. Thanks for your advice.

 

Mark.

0 Kudos
Message 3 of 6
(2,791 Views)

"Just getting things working" is how you end up with unmaintainable code.  First you add a little functionality here...add a little functionality there....and pretty soon, you have spaghetti code that is 3 or 4 screens wide.  You should always think about your base design architecture no matter how small the program (speaking from experience Smiley Wink)

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 6
(2,759 Views)

Just some more general code comments.

 

I am not sure why you are converting to byte array and back and use two FOR loops in sequence. You should combine the loops and operate on the strings directly. Here are some alternatives. Same result!

 

There are many other ways to do this, of course.

 

 

0 Kudos
Message 5 of 6
(2,743 Views)

Thanks a lot guys.

0 Kudos
Message 6 of 6
(2,706 Views)