LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading and writing from a file

Solved!
Go to solution

I am trying to read and write to a file so that I may store an array of string and a double in my application, but I have come upon a couple of problems; first when I put my file path into the path constant it will say that the file is not there ever though it is (so I have to force the issue and when the application asks for a file I have to browse and add the files), secondly when I run the program and it reads from the file it does not display the strings or doubles immediately instead I have to hit the submit button and than they finally come up, thirdly when I reset my values in the .txt files and put in my string and double and hit submit the array jumps one spot and starts at the index of 1 (array[1])  if anyone can help I would appreciate it a lot.

 

here is my code:

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Download All
0 Kudos
Message 1 of 8
(3,473 Views)

OK, first problem:

 

Right click on your path constant and browse for the path to the file you want.  That should make sure everything is right there.

 

Second problem:

 

The arrays won't update until some event occurs.  Since you only have two events, nothing will happen until you hit either the "submit" button or the "stop" button.  There are a number of solutions here, but the easiest way would be to hook up a 10 msec timeout to the event structure and then pass both arrays straight through.  I didn't try it, but it might cause some flickering. 

 

Third problem:

 

Didn't understand...  I'll try to mess around and get back to you.

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




Message 2 of 8
(3,463 Views)
Solution
Accepted by topic author Harold_Timmis

This is what I meant about the event structure and it should take of your second problem.  I didn't see the third.  I didn't see any flicker, but I have a slight vision problem which means I don't see flicker.  So it might flicker.  Or maybe not.  🙂

 

 

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




Message 3 of 8
(3,461 Views)

well first off i thank you I figured out the path and the array starting out in the index of one so no more of that I will try your delay to see if that works

 

here is my code:

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 4 of 8
(3,458 Views)

Harold Timmis wrote:

I am trying to read and write to a file so that I may store an array of string and a double in my application, but I have come upon a couple of problems; first when I put my file path into the path constant it will say that the file is not there ever though it is (so I have to force the issue and when the application asks for a file I have to browse and add the files),

 

I don't see that behavior at all about forcing the issue.  Why are you using Not a Path constants?  Why not turn those constants into controls you put on your front panel?

 

 

secondly when I run the program and it reads from the file it does not display the strings or doubles immediately instead I have to hit the submit button and than they finally come up,

Put your array indicators before your event structure rather than after.  Think dataflow.  The code pauses at the event structure waiting for an even to fire.  Only when it does (such as hitting the submit button) does the data get written to the array indicators. 

 

 

thirdly when I reset my values in the .txt files and put in my string and double and hit submit the array jumps one spot and starts at the index of 1 (array[1])  if anyone can help I would appreciate it a lot.

 

I don't see this behavior either.  How come your double.txt file has names in it, and your string.txt file has doubles in it?


 

Message 5 of 8
(3,453 Views)

yeah that was my fault the program is now running smooth with no glitches, but thank you for your input

 

 

 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 6 of 8
(3,451 Views)

Actually, I like Ravens Fan solution better than mine... putting the array before the event structure.  Then you don't need the timeout in the event structure.  I thought about that when I was looking at it and forgot it for some reason... 😞

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




Message 7 of 8
(3,449 Views)
It works perfect thanks raven fan
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 8 of 8
(3,442 Views)