LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open or create file doesn't allow creation of file


@Ben wrote:

Has anyone told you about the "light bulb" yet?

 

That button that looks like a light bulb will put your code in execution highlighting mode.

 

I suspect that if you put your code in light-bulb mode and then run you V and then click the Measure button....

 

You will see the event case will fie and the value of the measure button BEFORE the event fired will be passed tot he loop. That same value will be used for every iteration of the internal loop.

 

For you to be able to stop that loop, you will have to read the button INSIDE the loop to get it's current value.

 

Also note that the stop contion can be set to "Stop if true" or "Run if true" by right clicking the stop terminal.

 

And while you are in light-bulb mode, you may also notice an error if any.

 

Ben

 

 


Thanks Ben, I've got the light bulb thing it is a helpful tool....and thanks on your other notes 😉

0 Kudos
Message 11 of 38
(1,658 Views)

@Ben wrote:

In the background of the error message it looks like you have a "open" enum wired to the Open/create file VI. Use the hand tool to select "Open or create" and try it again.

 

Ben 


Yes I was trying some different things to see if I could get it to work, I originally had Open or create and I also tried see attached.

 

I think the problem is the Path, when you click on the icon to get the file the title of the window is always open

Download All
0 Kudos
Message 12 of 38
(1,654 Views)

Put a probe on your path wire and wathc it light-bulb mode. The boolean being returned from the "check if file or folder exist" can be used to check for eithr folders or files.

 

Play with it a bit and watch it. You are a smart guy, you will figure it out.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 13 of 38
(1,649 Views)

my smartness is relative at times

0 Kudos
Message 14 of 38
(1,646 Views)

Here is another question for you though.  If the file already exists, do you want to replace it (essentially deleting the old file and starting a new one) or add on to it?  If you want to replace, you need to use the "Create or Replace" option for the Create/Replace/Open File.  If you are adding on to it, then you need to use the Set File Position to set the position to the end of the file.  In either case, you do not need to check to see if the file exists nor that case structure as shown in the image file.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 15 of 38
(1,631 Views)

@rr1024 wrote:

 I think the problem is the Path, when you click on the icon to get the file the title of the window is always open

Yes I was trying some different things to see if I could get it to work, I originally had Open or create and I also tried see attached.
  • Why are you building a path with an empty string diagram constant? What result are you expecting from it?
  • You still have the dataflow problem with the stop condition of the inner loop as we told you days ago.
  • There is also a race condition because once the event fires, there is most likely stale data in the boolean tunnel because the switch has been read long ago. You get the exactly opposite value inside the event compared what you think you get. The terminal belongs inside the event so it gets read after the event fires and you get the new value! Think dataflow!
  • Your event locks the front panel, locking up the VI forever because there is no way to top the inner loop.
  • Why is there a timeout event if you don't use it?
  • Why is there a breakpoint around the case structure?
  • How exactly are you planning to stop the outer loop and end the program?

Please reduce the VI to a single task: opening or creating a file so we can also run and test it. We don't have any of your instruments!

Attach that new and simplified VI and tell us exaclty how you are using it, what you expect to happen, and what you observe instead. Isolate the problem!

Thanks!

0 Kudos
Message 16 of 38
(1,611 Views)

@altenbach wrote:

@rr1024 wrote:

 I think the problem is the Path, when you click on the icon to get the file the title of the window is always open

Yes I was trying some different things to see if I could get it to work, I originally had Open or create and I also tried see attached.
  • Why are you building a path with an empty string diagram constant? What result are you expecting from it?
  • You still have the dataflow problem with the stop condition of the inner loop as we told you days ago.
  • There is also a race condition because once the event fires, there is most likely stale data in the boolean tunnel because the switch has been read long ago. You get the exactly opposite value inside the event compared what you think you get. The terminal belongs inside the event so it gets read after the event fires and you get the new value! Think dataflow!
  • Your event locks the front panel, locking up the VI forever because there is no way to top the inner loop.
  • Why is there a timeout event if you don't use it?
  • Why is there a breakpoint around the case structure?
  • How exactly are you planning to stop the outer loop and end the program?

Please reduce the VI to a single task: opening or creating a file so we can also run and test it. We don't have any of your instruments!

Attach that new and simplified VI and tell us exaclty how you are using it, what you expect to happen, and what you observe instead. Isolate the problem!

Thanks!


 

Currently we are not trying to solve most of the issues you raise, such as but not limited to:

  • You still have the dataflow problem with the stop condition of the inner loop as we told you days ago.
    • There is also a race condition because once the event fires, there is most likely stale data in the boolean tunnel because the switch has been read long ago. You get the exactly opposite value inside the event compared what you think you get. The terminal belongs inside the event so it gets read after the event fires and you get the new value! Think dataflow!
      • Why is there a timeout event if you don't use it?
      • Why is there a breakpoint around the case structure?
      • How exactly are you planning to stop the outer loop and end the program?

 

However, in this thread we are working on the file creation and of course the path problem and to answer your question "Why are you building a path with an empty string diagram constant? What result are you expecting from it?" 

As I told you days ago I'm new to LabView but not programming and I was mistakenly lead to beleive that LavView was more powerful tool than it actually is and a perfect example is if you compare the first VI I uploaded with this this one I was expecting the VI to work similarly.

 

Also if you are here to help, if you don't have the instraments as you stated above, "We don't have any of your instruments!", and you have labView and you are an expert then you can use a delete key. Unless you keyboard doesn't have one?

 

I help people all the time on Stackoverflow, phpfreaks and other places and when newbies to the langauge that I'm an expert at I always try to be helpful and show/lead by example. 

 

So thank you for your help but I mangaged to figure out that for some reason I have to strip a path from a path dialog and then build it again even thought the path and file are already in  the path. That is a bit on the quarky side, I do realize that all the other languages I know all have some quarky things, usually compile issues but non are perfect but file handly should be more straight forward I think.

0 Kudos
Message 17 of 38
(1,563 Views)

@rr1024 wrote:So thank you for your help but I mangaged to figure out that for some reason I have to strip a path from a path dialog and then build it again even thought the path and file are already in  the path. That is a bit on the quarky side, I do realize that all the other languages I know all have some quarky things, usually compile issues but non are perfect but file handly should be more straight forward I think.

No need to get snarky. as I said, if you have problems with file creation, reduce the attachment to that single task, especially if the rest of the code is senseless, pointless and rube goldberg'ish in gigantic propotions. If you don't we will comment of the entire picture.  If you bring your car to a mechanic because the tail light does not work, he might point out that the transmisison is missing and that the car is on fire, even though you insist that everything else is fine.

 

Your construct of stripping/building is a NOOP unless the original path contains garbage, e.g. spaces or illegal characters. Do you use the browse button are are you typing the path yourself?

 

Can you enter your path, right-click the path control and do a  "data operations...make current value default". Now attach the VI again so we can analyze what you enter there and test for ourselves.

 

I know you don't want to hear it, but your code got sigificantly worse! 😮 Are you serious or are you trying to make fun of us? Event structures never belong inside event structure. Just looking at the code for 2 seconds it is clear that the VI can never work. Pressing any button while the VI is running locks up the front panel forever.

 

Obviously, you have not grasped the idea of dataflow programming, so maybe LabVIEW is not for you after all.


rr1024 wrote: 
As I told you days ago I'm new to LabView but not programming and I was mistakenly lead to beleive that LavView was more powerful tool than it actually is and a perfect example is if you compare the first VI I uploaded with this this one I was expecting the VI to work similarly.

If you are new to LabVIEW, you should wait until you form an opinion until you are more familiar with it. This is engineering, not politics. 😄

 

Do you really think that big organizations such as SpaceX, Cern (e.g. LHC), GM, Ford, etc. use LabVIEW for purely sentimental reasons?

 

 


@rr1024 wrote:
I help people all the time on Stackoverflow, phpfreaks and other places and when newbies to the langauge that I'm an expert at I always try to be helpful and show/lead by example. 

We are very helpful here, just look at all the other posts! I am sure that if you encounter a stubborn, in denial, know-it-all on stackoverflow, You will give up after a few tries. In contrast, I am still answering here. 😄

Message 18 of 38
(1,552 Views)

@rr1024 wrote:
I have to strip a path from a path dialog and then build it again even thought the path and file are already in  the path. That is a bit on the quarky side, I do realize that all the other languages I know all have some quarky things, usually compile issues but non are perfect but file handly should be more straight forward I think.

Aside from all the other back and forth that's going on, what you've done is completely unnecessary. The Open or Create option does do exactly what you've forced in your code. If it's not, then there's something wrong with your path. Stripping and Building your path as well, not something I've ever seen needed before.

In my first reply, I asked "What path are you trying to use?". I bet if you had responded with your path, we could have pointed something out there that is causing your issue.

 

What you're doing here is adding extra parsing steps and hoping the translation functions work magic to fix your bad path. Please include your VI with the path set as default, so we can run the code the same way you are. That's the only way to get to the real bottom of this, instead of the see-what-sticks method.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 19 of 38
(1,544 Views)

Really, calling me a stubborn know it all and you are still helping me, that is hilarious Smiley LOL, especially when I've told you twice, I know NOTHING about LabView and yes that means "dataflow programming". I just started seriously trying learn labview last week, you must be Smiley Surprised

 

One of the only things you said useful in your post above was "Event structures never belong inside event structure." to that I say, thank you and I did not know this. That is actually kind of helpfule especially since this will be the 3rd time, I'm a Newbie.  Just in case you are not aware of what a "newbie" is, it is someone who is new and this generally means they don't posses the knowledge that pro's like  yourself take for granted. You can even look it up on google 😉 but you won't have to because I'll be helpful and post it here.

Newbie - an inexperienced newcomer to a particular activity.

 

You know what I do when I'm helping people with languages that are unfamilure to them and they post thier source code? I use my delete key to get rid of the useless bits so I get them to focus on the question asked and if I have any other advice about other parts of their code I'll usually post the code snipets both before and after so they can compare for their selve to see what they did and how it should or could be better. Just some food for thought.

 

 

Now the thing about text based languages, using the delete key can make the program non-operation or NOOP it but guess what? You don't have the same problem with labview or at least to the extent the text base langueges do.

 

 

0 Kudos
Message 20 of 38
(1,531 Views)