LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create file errors

Solved!
Go to solution

Hello

 

I got a problem with creating a new file when I start running my code. I set it to be "open or create". As I read in the context help, when there is no file in the file path, it should create a new automatically but it didn't.  When I deleted the file in file path on the front panel, error 1 occured. There is no problem with "open" when the file exists.

 

I want my vi to create a new file every time I start running my code and save it, then recreate another file in the next run.

 

Thanks!

 

 

Download All
0 Kudos
Message 1 of 16
(3,346 Views)

I think you may be misunderstanding the default value for File Open/Create.

 

If you wire a control to the File Open, it will use the value of the control regardless of whether that value is empty or valid.

If you don't wire anything to the File Path input of File Open, then it will open a dialog.

 

For your case, you may want to do some checking on the control path validity before doing the file open.

 

Why not put the File Open logic in your Event structure?

 

Your architecture as it stands is a bit odd.  You have an event loop but exit of your event loop is a prerequisite to running the rest of your program.

 

Also, you likely don't need any of those local variables.

 

 

0 Kudos
Message 2 of 16
(3,340 Views)

Hi,

 

I couldn't run your code as some VIs were missing. Anyway, Try the attached example. It may help you. What is the error that you are getting?


Regards,
Nitz 

(Give Kudos to Good Answers, Mark it as a Solution if your problem is Solved:smileywink:)  

0 Kudos
Message 3 of 16
(3,333 Views)

more subvi

0 Kudos
Message 4 of 16
(3,330 Views)
0 Kudos
Message 5 of 16
(3,328 Views)

@ Taki1999

 

How to do the checking on the control path?

 

Could you please make some changes on my vi? I am so confused now.

 

The reason I have the event loop as a prerequisite before the main loop is running is about user interface. I want the user to adjust everything before running. Im not sure if it's a good idea but it has been working correctly as I want so far.

 

 

0 Kudos
Message 6 of 16
(3,324 Views)

@Bombbooo wrote:

@ Taki1999

 

How to do the checking on the control path?

Use Is Empty String/Path? from the Comparisons Palette.  You might also consider using the File Dialog from the FileIO Palette->Advanced.

 

Could you please make some changes on my vi? I am so confused now.

I'll give it a look.  I recommend you start using LabVIEW projects and then create zip files.

 

The reason I have the event loop as a prerequisite before the main loop is running is about user interface. I want the user to adjust everything before running. Im not sure if it's a good idea but it has been working correctly as I want so far.

 

I'm guessing there's a better architecture.  Your current setup will require you to restart the program on every run.  I think a more natural behavior would allow the user to keep the program open and just hit the run button again.  Look into a state machine for this.

 

 


 

0 Kudos
Message 7 of 16
(3,315 Views)

I made some comments on your vi.

 

Additionally, you may want to start reading up on State Machines.

State Machines

0 Kudos
Message 8 of 16
(3,310 Views)

can you save it in 2010 version? Thanks

0 Kudos
Message 9 of 16
(3,307 Views)

@Bombbooo wrote:

can you save it in 2010 version? Thanks



Now in 2010.

0 Kudos
Message 10 of 16
(3,305 Views)